[XML-SIG] Need an equivalent to Perl's XML::Parser "Tree" style
Greg Stein
gstein@lyra.org
Tue, 6 Jun 2000 11:47:00 -0700 (PDT)
Quite an easy answer, actually :-)
In the PyXML distro, take a look at xml.utils.qp_xml. If you have PyXML
0.5.5, then you're fine. Otherwise, the most recent copy can be fetched
from:
http://www.lyra.org/greg/python/qp_xml.py
It constructs very lightweight Python objects for the elements. It also
does so quite quickly :-), although I've got even more speed improvements
on deck from Bjorn Pettersen.
Cheers,
-g
On Tue, 6 Jun 2000, John Posner wrote:
> Hi --
>
> Back when I was a Perl hacker (more of a dabbler, really), I had good luck
> creating an object that represents an entire XML document, using this call:
>
> new XML::Parser(Style => Tree)
>
> Here's a description, in Python terms, of the recursive data structure
> created by the above call:
>
> --------------------------------------------------------------------
> The E-NODE representing the root element is a 2-item list:
>
> * item 0 = string containing name of element
>
> * item 1 = another 2-item list:
> * item 0 = a dictionary containing element's attributes
> * item 1 = a list containing multiple 2-item lists:
>
> * one of these 2-item lists captures the element's character data:
> * item 0 = string "0"
> * item 1 = string containing element's character data
>
> * each other 2-item list is an E-NODE representing a subelement
> --------------------------------------------------------------------
>
> QUESTION: what set of Python tools comes closest to creating a data
> structure similar to, or exactly like, the above?
>
> Thanks!
> John
>
> --
> John Posner, Editor jjp@oreilly.com
> O'Reilly & Associates 860-663-3147
>
>
> _______________________________________________
> XML-SIG maillist - XML-SIG@python.org
> http://www.python.org/mailman/listinfo/xml-sig
>
--
Greg Stein, http://www.lyra.org/