Skip to content

Instantly share code, notes, and snippets.

@murarisumit
Last active September 14, 2015 17:12
Show Gist options
  • Save murarisumit/32c2bbe976924e94047c to your computer and use it in GitHub Desktop.
Save murarisumit/32c2bbe976924e94047c to your computer and use it in GitHub Desktop.
Parsing XML in python #xml #python #parsing
  1. Using elementtree for that...

In order to install it: pip.exe install elementtree --allow-unverified elementtree ( i don't why --allow-unverified elementtree)

example :

    from xml.etree import ElementTree
    document = ElementTree.parse("file.xml")
    connections = document.find('users')   #searching for element in xml tree
    for connection in connections.findall('user'):
	    print connection.attrib['name']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment