[XML-SIG] newbie question on loading/saving xml files

paul@boddie.net paul@boddie.net
24 Oct 2001 07:59:11 -0000


Mark Humphrey <mark.humphrey@acm.org> wrote:
>

[Loading files]

>The FromXMLStream function takes a file stream as an input and outputs a DO=
>M tree, if the file stream was properly structured XML.  You get to it with:
>	from xml.dom.ext.reader.Sax import FromXmlStream

Shouldn't this be...

  from xml.dom.ext.reader.Sax2 import Reader
  # Get a Reader.
  reader = Reader()
  # Use the fromStream method of reader to get a document.
  doc = reader.fromStream(stream)

This is off the top of my head, but I did change my code in the past few days 
to use fromStream, and not the FromXMLStream function, which is apparently 
deprecated. Also, I think the Sax2 module is recommended over Sax these days.

>After that, everything you do just consists of DOM tree manipulations, and
>you should be able to find good documentation on the DOM from the w3c web s
>ite (www.w3c.org).  PyXML has an odd mix of DOM level 1 and level 2 functio
>ns implemented, and I think I've even found a few random level 3 functions
>have been implemented.  Not sure what the exact pattern is, though.

Sadly, it's a case of reading the source for the most part, but I've become 
used to that. Having said that, there are a few books out which could be 
helpful, the most recent of which seems to be "Definitive XML Application 
Development" by Lars Marius Garshol, and a presentation of that book seems to 
be taking place where I work tomorrow. It looks like Python is emphasised quite 
a bit in that work.

Paul

-- 
Get your firstname@lastname email for FREE at http://Nameplanet.com/?su