How to parse XML in python
Talk1
1,792pages on
this wiki
this wiki
Redirected from Howto parse XML in python
Python have a XML modules to parse trees. You can use it to store and receive data from text files (.xml extension is not required). There is many editors to edit trees (See Links below to find one).
Contents |
ElementTree
Edit
Loading files
Edit
#importing module as ET for easiest writing
from xml.etree import ElementTree as ET
#parse file test.xml. In result we get ET.ElementTree object
document=ET.parse("test.xml")
#print the main node name
mainnode.document.getroot()
print mainnode.tag
test.xml
<mainnode>
<node>
<textnode>this is a text inside a node.</textnode>
</node>
</mainnode>
See:
Edit
Editors to edit xml tree
Edit
From HowTo Wiki, a Wikia wiki.