[XML-SIG] Reader() newbie question

Steve Barlow barlow@forwiss.uni-passau.de
Wed, 27 Jun 2001 21:45:30 +0200


Hi,
  I am just starting out with XML and python so these questions might be
REALLY silly.  Sorry.  My basic first goal is to read an XML file into a DOM
tree with validation.  I am a little confused about which of the following
methods is most appropriate.  My first try was simply something like this...

from xml.dom.ext.reader import Sax
xml_object = Sax.FromXmlFile(filename, validate=1)

O.K. I figured out that the FromXmlFile method is deprecated and I should
switch to FromXmlUri (I think).  I also think that this then uses xmlproc as
the parser.  Is this correct?  I also saw that these FromXml* methods have
the argument "parser = none."  Assuming I could say something like
"parser=xmlproc" (and I am honestly not sure what exactly parser= does) is
there any advantage to "parser=" over "validate="?

Where my confusion really starts is that in most examples I have seen (i.e.
xmldoc/doc/demo/dom) a slightly different method seems to be used, i.e...

from xml.dom.ext.reader import PyExpat
from xml.dom.ext.reader import Sax
reader = PyExpat.Reader()
xml_object = reader.fromUri(xmluri)

This is fine, but I really want a validating parser.  Is is possible for me
to do something like reader=ValidatingParser.Reader()?  Which validating
parser can I instanciate like that?  xmlproc? What are the advantages from
one method over the other?

Thanks a lot for the help -  being a newbie can but fun and frustrating at
the same time.  If these are questions that I should have been able to
quickly answer from the documentation I would appreciate a pointer to the
right place/doc so that I don't need to waste people's time in the future.

Steve