简体   繁体   中英

How to read in xml header/version using python

I'm looking for a way to read in the XML version header using the xml.sax parser in python.

**<?xml version="1.0"?>**
<root>
  <child>Hello</child>
  <child2>World</child>
</root>

So far, whenever I try to read in the XML, it just seems to skip over the header and go to the root node.

Any help would be greatly appreciated.

Thank you.

I am not sure if this is available in your version of SAX, but the way to get it would be through the Locator2 .

http://sax.sourceforge.net/apidoc/org/xml/sax/ext/Locator2.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM