[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: How to get the inner html of a href link.



>>>>> 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.