Skip to content

Instantly share code, notes, and snippets.

@milosh-96
Created May 16, 2017 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milosh-96/1c9256b9ceeb1ce34151e56599d46b8d to your computer and use it in GitHub Desktop.
Save milosh-96/1c9256b9ceeb1ce34151e56599d46b8d to your computer and use it in GitHub Desktop.
import xml.etree.ElementTree as ET
import urllib
xml = urllib.urlopen("https://www.w3schools.com/xml/books.xml")
tree = ET.parse(xml)
root = tree.getroot()
cat = raw_input('Kategorija: ')
for child in root:
if child.attrib.get('category') == cat:
print child[0].text
print child[1].text
print child[2].text
print '$ ' + child[3].text
print '-------------'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment