June 2000
Intermediate to advanced
556 pages
8h 45m
English
Walking a tree in Pyxie is analogous to walking a tree by using the event-driven style, with the exception that you have full access to the XML document structure. In this program, a function Handler is called twice for every node in the XML tree: once when the node is encountered “on the way down” in a depth-first, left-to-right tree walk, and again when the node is encountered “on the way up.”
CD-ROM reference=12023.txt
C>type p21.py """ Print XML summary, using event-driven tree walk. """ from pyxie import * def Handler(tree,StartOrEnd): if tree.AtElement(): if StartOrEnd==1: print "Start Element:",tree.ElementTypeName else: print "End Element:",tree.ElementTypeName else: if StartOrEnd: print "data:%s..." % tree.Data[:4] ...Read now
Unlock full access