from lxml import etree
tree = etree.parse("http://distrowatch.com/news/dw.xml")
root = tree.getroot()
for channel in root:
for item in channel:
print(item.text)
This prints out a good chunk of data from the xml file, but what I'd really like to do is print out only the <title> of the feed headline, which is contained within the <item> tag. At first I thought of doing something like this:
for channel in root:
for item in channel:
print(item[0].text)
But that didn't work, as I got a 'list index out of range' error.

New Topic/Question
Reply



MultiQuote




|