ElementTree
モジュールを使用してPythonでXML文書を解析しようとしています。私は、特定のipAddress
に等しいそのタグ内のentry
とname
という属性を持つElements
を探しています。以下は私のコードは、これまでのところです:私はfor
ループ内のコードprint child.tag, child.attrib
を使用する場合名前属性のXMLタグを検索:Python elementTreeモジュール
tree = ET.parse(fi2)
root = tree.getroot()
for child in root.iter('entry'): #looks through child elements for tag=entry
#look for elements that have an attribute(name)='string'
、私は次のような出力が得られます。
entry {'name': 'ipAddress'}
私はentry
タグの検索支援が必要ipAddress