dynamic naming for hierarchical problem

Peter Hansen peter at engcorp.com
Wed Aug 8 23:40:25 EDT 2001


Jeremy Jones wrote:
> 
> I have a web application that I need to test by HTTP posting different sets
> of data to it.  The hierarchical data model that I want to create will allow
> me to create different sets of tests each containing different sequences of
> data to post to the server and store the results of the test.  I want to be
> able to navigate through this hierarchical set of data using Tix.Tree.

No idea what that (Tix) is...

> (Plus, it will be fun and cool and really geeky! :-)

(Always a valid requirement for doing something. :)

> > Nevertheless, a lot of what you refer to above
> > seems to be provided by the Document Object Model
> 
> I will have to check out DOM tomorrow and see if it will help or not.  I
> have never messed around with XML, but I had actually thought about defining
> my tests in XML (another fun, cool, geeky thing to do) and parsing it with
> Python.  Is it fairly straightforward to keep the hierarchical structure of
> an XML/DOM document so that you can navigate down it (particularly in this
> instance - using a Tree widget)?

XML is used to represent the tree/hierarchy in a text file.  When you
parse it in using an XML parser, you end up with the data stored 
in the DOM.  That is, the DOM *is* the internal representation
in this case, so I guess, Yes, you can keep the hierarchical structure
of the XML data since that's the whole point of the DOM.  Access
to children and parents, manipulations in-memory, etc.  There
are other techniques/parsers, such as SAX, which might even
fill your needs better.  This is not going to be a ten-minute
job. :)

As for Tree widgets... definitely the DOM can map to the widget
and vice-versa, and depending on what Tix is, you may even find
examples of this ready-made for you.  I definitely remember 
seeing some simple code that would parse XML into memory and
represent it in a tree widget.  Mind you, that may have been
back in my Java days... :(  I hope someone else can point
you to a reference of doing this with Tix or something in Python.

-- 
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com



More information about the Python-list mailing list