User:Pluke/xml
Jump to navigation
Jump to search
- -------------------------------------------------------------------------------
- Name: module1
- Purpose:
- Author: pluke
- Created: 03/03/2013
- Copyright: (c) pluke 2013
- Licence: <your licence>
- -------------------------------------------------------------------------------
- tkinter drop downs
- http://effbot.org/tkinterbook/optionmenu.htm
- instructions on how to use xml functions
- http://docs.python.org/2/library/xml.etree.elementtree.html#building-xml-documents
def main():
pass
if __name__ == '__main__':
main()
import xml.etree.ElementTree as ET
tree = ET.parse('c:/tmp/test.xml')
root = tree.getroot()
- print root.tag
- print out each word
for child in root:
print child.find('length').text print child.get('value')
- <?xml version="1.0"?>
- <dictionary>
- <word value="cat">
- <length>3</length>
- </word>
- <word value="dog">
- <length>11</length>
- </word>
- <word value="mouse">
- <length>2</length>
- </word>
- <word value="rat">
- <length>0</length>
- </word>
- </dictionary>