How to read in header / xml version using python

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

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

For now, whenever I try to read in XML, it just skips the header and goes to the root of the node.

Any help would be greatly appreciated.

Thank.

+1
source share
1 answer

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

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

0
source

Source: https://habr.com/ru/post/1694025/


All Articles