HTML / DOM
Bo M. Maryniuck
b.maryniuk at forbis.lt
Fri Mar 28 21:32:20 CET 2003
Can anybody drop me a real code how to work with DOM in _HTML_ which is even
not XHTML? I took a look over 4DOM but unfortunately documentation there is
too silly. :( Well, for example, I have a HTML string:
<p>Text here <a name="foo">bar</a></p>
Now, how to build a DOM from this chunk to do the following:
1. Fetch somehow a "name" attribute from the "<A/>" tag
2. Change it (not a "bar", but a "foo" value!)
3. Push it back to the same place
4. Return modified HTML back as string without doctype and so on.
Any ideas? I know how to work with XML, but HTML-stuff drives me crazy since
it does not XML. Yes, I've tried to RTFM and STFW, but now I gave up -- this
all does not work as I need.
What I need to do with it. I have a HTML's where I need to found all the tags
<a name="foo"> which contains Unicode data in the "name" attribute and
urllib.quote() it than return this HTML back. But how to do it with DOM in
HTML -- I have no idea, since this is not XML... :(
Thank you for any help and any *working* ideas and examples. :)
If vegetarians eat vegetables, what do humanitarians eat?
More information about the Python-list