June 2000
Intermediate to advanced
556 pages
8h 45m
English
We can now navigate at will through an xTree structure, but how do we build the structure in the first place?
We could build up the structure “by hand” by using xTree, xData, and xElement objects.
CD-ROM reference=9007.txt
t = xTree()
t.RootNode = xElement("greeting")
t.CurPos = r.RootNode
t.Down()
t.CurPos.Bottom = xData("Hello World")
This program builds a tree that corresponds to the following XML document.
CD-ROM reference=9008.txt <greeting> Hello World </greeting>
To better see the correspondence between the Python data structure and the XML file, let us add a couple of methods that will allow us to print XML from these structures easily.
You will remember from chapter 5 that Python allows you to take ...
Read now
Unlock full access