uche at ogbuji.net
Thu Dec 21 17:01:06 CET 2000
Alex Martelli wrote:
> <ennisr at my-deja.com> wrote in message news:91lsh8$9p7$1 at nnrp1.deja.com...
> > I am a relative newbie to Python, using Python 2.0 under Windows.
> > 4DOM from Fourthought, Inc. has also been installed.
> > I have run into a problem trying to run the DOM examples from David
> > Mertz article "Charming Python: The dynamics of DOM"
> > (http://gnosis.cx/publish/programming/charming_python_2.txt).
> > Modules referenced in the following import statements seem to be
> > missing.
> > from xml.dom import core
> > from xml.dom.html_builder import HtmlBuilder
> > from xml.dom.utils import FileReader
> > Do I have the wrong software loaded? Where can I find the missing
> > modules?
> I think you need the PyXml stuff, e.g. from
> probably in some older version.
> 4DOM may have equivalent or better functionality, but
> I suspect it will not match what you read in that
> online book, which appears to target older PyXml stuff.
Actually, PyXML now incoporates 4DOM as its DOM library. The old code
mentioned above is no longer maintained by anyone.
Here is code given in the article
from xml.dom import core
from xml.dom.html_builder import HtmlBuilder
# Construct an HtmlBuilder object and feed the data to it
b = HtmlBuilder()
# Get the newly-constructed document object
doc = b.document
# Output it as XML
And here is how it would look in PyXML or 4DOM
from xml.dom import ext
from xml.dom.ext.reader import HtmlLib
#Create a reusable reader object
reader = HtmlLib.Reader()
#Construct a DOM from stdin
doc = reader.fromStream(sys.stdin)
#Output the HTML as XHTML
Personal: uche at ogbuji.net http://uche.ogbuji.net
Work: uche.ogbuji at fourthought.com http://Fourthought.com
More information about the Python-list