How to read in xml header/version using python

社会主义新天地 提交于 2019-12-11 14:32:13

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/16155102/how-to-read-in-xml-header-version-using-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!