pyXML exceptions

O

Odd Bjornstad

Hello



Am parsing xml with pyXML and using the following code:



from xml.parsers.xmlproc import xmlproc

from xml.parsers.xmlproc import xmlval

from xml.parsers.xmlproc import xmldtd



..

..





def parser(xml,dtd):

print 'Start XML Parsing'

d = xmldtd.load_dtd(dtd)

p = xmlval.XMLValidator()

p.set_application(MyApp())

p.feed(xml)

#-à here I want to get some form of control over the messages (if syntax/
other error) that the parser print into console

print 'End XML Parsing'

..

..

..





I need to catch the messages thrown by the parser when there are syntax
errors in the XML or DTD.

These messages seems to be exceptions but it's a bit confusing not being
able to catch them.

Now I only get messages printed in the console but I want to put the
messages into a logfile or database table.



Any suggestions ?



Regards
Odd Bjørnstad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top