Skip to content

Instantly share code, notes, and snippets.

@takaki
Created October 22, 2012 09:14
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 takaki/3930537 to your computer and use it in GitHub Desktop.
Save takaki/3930537 to your computer and use it in GitHub Desktop.
simple lxml sample
#!/usr/bin/python
from lxml import etree
tree = etree.parse(open('database.xml'))
blogs = tree.xpath('//row[user_id=5]')
for b in blogs:
print b.find('blog_id').text
print b.find('user_id').text
print b.find('cat_id').text
print b.find('created').text
print b.find('title').text
print b.find('contents').text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment