startElementNS
Martin v. Löwis
loewis at informatik.hu-berlin.de
Thu May 2 09:05:23 EDT 2002
"Achim Domma" <achim.domma at syynx.de> writes:
> can somebody give me a minimal example how to use namespace processing with
> SAX ?
This works for me:
from xml.sax import make_parser, ContentHandler
from xml.sax.handler import feature_namespaces
import StringIO
class MyHandler(ContentHandler):
def startElementNS(self, name, attrs, attrsNS):
print "Start",name, attrs, attrsNS
doc = "<bar:foo xmlns:bar='http://www.loewis.de/demo'/>"
p = make_parser()
p.setContentHandler(MyHandler())
p.setFeature(feature_namespaces, 1)
p.parse(StringIO.StringIO(doc))
Regards,
Martin
More information about the Python-list
mailing list