[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to get the inner html of a href link.
- From: Katsumi Yamaoka <yamaoka@xxxxxxx>
- Date: Thu, 12 Mar 2009 07:41:23 +0900
- X-ml-name: emacs-w3m
- X-mail-count: 10760
- References: <87ocw9mrfa.fsf@xxxxxxxxxxxxxx> <b4mwsaw4zuv.fsf@xxxxxxx> <87r614taw6.fsf@xxxxxxxxxxxxxx>
>>>>> In [emacs-w3m : No.10759] netawater wrote:
> Katsumi Yamaoka <yamaoka@xxxxxxx> writes:
>> (defun my-w3m-href-text (&optional position)
[...]
> Thank you very much! It works well.
> however it seems it is not easy to get html attribute in w3m which
> does not implement DOM, is it?
The `w3m-parse-attributes' macro, used here and there in emacs-w3m,
is it. This extracts KEYWORD="VALUE" attributes within a tag:
(w3m-parse-attributes (KEYWORD [KEYWORD...])
(Lisp forms that use KEYWORDs))
KEYWORD can be (KEYWORD TYPE), where TYPE is one of `:case-ignore',
`:integer', `:bool', and `:decode-entity'. For example:
(with-temp-buffer
(insert "<a href=\"http://www.example.com\"\
fOo=\"FoO-vAlUe\"\
BaR=\"bAr-VaLuE\">\n")
(goto-char 2)
(w3m-parse-attributes (foo (bar :case-ignore))
(list foo bar)))
=> ("FoO-vAlUe" "bar-value")
The point has to be within the tag, and only attributes that follow
the point will be extracted.