Yikes, I can't seem to turn on namespace mode and get my contentHandler's startElementNS and endElementNS called. Instead it is still calling startElement and endElement. Here's how I'm setting it up:
source = open(sourceFileName)
xml_parser = xml.sax.make_parser()
handler = MyContentHandler()
xml_parser.setContentHandler(handler)
xml_parser.setFeature(xml.sax.handler.feature_namespaces, True)
xml.sax.parse(source, handler)
How do I turn on namepace mode so it calls startElementNS etc?
The last line (xml.sax.parse(source, handler)) creates a new parser. You are not using the xml_parser object for which you have set up namespace mode.
It should work if you change this line to
xml_parser.parse(source)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With