June 2000
Intermediate to advanced
556 pages
8h 45m
English
In this program, an HTML file is loaded and re-created as an XML file. The principal difference between loading HTML and loading XML into the DOM is that an HTML-specific building module called HtmlBuilder is used.
CD-ROM reference=11011.txt """ Accessing an HTML document with DOM """ from xml.dom import core from xml.dom.html_builder import HtmlBuilder import StringIO,string h = HtmlBuilder() h.feed ( '<html>' '<head>' '<title>' 'Hello World' '</title>' '</head>' '<body>' '<h1>Title of document</h1>' '<p>Hello<br> World' '</html>') doc = h.document print doc.toxml() CD-ROM reference=11012.txt <HTML> <HEAD> <TITLE>Hello World</TITLE> </HEAD> <BODY> <H1>Title of document</H1> Hello</BR />World</P> </BODY> ...
Read now
Unlock full access