0
私が持っていれば、このようなXMLファイル:ElementTreeを持つXML文書の名前空間定義をリストしますか?
<root
xmlns:a="http://example.com/a"
xmlns:b="http://example.com/b"
xmlns:c="http://example.com/c"
xmlns="http://example.com/base">
...
</root>
どのように私は名前空間の定義のリスト(すなわち、xmlns:a="…"
、など)を得ることができますか?使用
:
import xml.etree.ElementTree as ET
tree = ET.parse('foo.xml')
root = tree.getroot()
print root.attrib()
は、空の属性辞書を表示します。
ここでは、ElementTreeので行うことができる方法であります:http://stackoverflow.com/a/42372404/407651 – mzjn