[XML-SIG] How to parse an XML in SAX

Stefan Behnel stefan_ml at behnel.de
Mon Nov 12 12:06:56 CET 2007

[going back to the list]

Alexandro Colorado wrote:
> On Sun, 11 Nov 2007 21:38:21 -0600, Stefan Behnel <stefan_ml at behnel.de>
> wrote:
>> The tool I actually mentioned, cElementTree, should also work just
>> fine on
>> 2.3. Note also that ElementTree (without the 'c') is pure Python, so it
>> doesn't require you to compile anything.
> Thanks for selling me into ElementTree however I cant because the
> version of the Python distribution that is being shipped doesn't has
> element tree so this make this a particular situation that I can only
> used the standard libraries.

I'm not sure I understand this. You are writing Python code, right? Why can't
you just add another Python source file? (such as ElementTree.py)


> Now going back to SAX, is there a way I can escape the non-printable
> characters and how exactly they get into it on the first place. SAX is a
> very quick parser from what I've read. I have found this tutorial
> between python and SAX:
> http://www.devarticles.com/c/a/XML/Parsing-XML-with-SAX-and-Python/
> I have move on to read other tutorials to see if they can address this
> current issue. I am interested on this parsing specifically to see a way
> of escaping or 'passing' the print out of special characaters:
>     def endElement(self,name):
>         if (name == "img") :
>             print "%8s %s" % (self.name, self.title)
>             self.name = self.title = "" # just for safety
>         if (name == "title") :
>             pass
> Not sure what %8s and %s compared to escaping the /t or /n.

More information about the XML-SIG mailing list