Created
October 22, 2012 09:14
-
-
Save takaki/3930537 to your computer and use it in GitHub Desktop.
simple lxml sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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