T
thiefmn6092
Guest
XML is very useful when it comes to using it as a database or anything similiar. I'll explain the easiest way to use it in Python here
Here is our sample XML file.
1. Imports
2. Loading the XML file.
The above code will open the file "YourFile.xml" into dom and hold it in memory.
3. Extracting data ( SIMPLEST )
4. Displaying the data ( SIMPLEST )
[/code]
Here is our sample XML file.
Code:
<Sample>
<SomeTable>
<Attack>1</Attack>
</SomeTable>
</Sample>
1. Imports
Code:
from xml.dom import minidom
2. Loading the XML file.
Code:
xmldoc = minidom.parse('YourFile.xml')
The above code will open the file "YourFile.xml" into dom and hold it in memory.
3. Extracting data ( SIMPLEST )
Code:
attack = xmldoc.getElementsByTagName('Attack')[0].firstchild.data
4. Displaying the data ( SIMPLEST )
Code:
print attack

