I have this code that is working, but how can I load item value instead of object itself and record it into array.
import urllib
import xml.etree.ElementTree as xml
tree = xml.parse(urllib.urlopen('http://lazhalazha.livejournal.com/data/rss'))
rootElement = tree.getroot()
for a in rootElement.findall('channel/item/guid'):
print a
Outputs
<Element 'guid' at 0xb75316ec>
<Element 'guid' at 0xb7531a0c>
<Element 'guid' at 0xb7531c8c>
<Element 'guid' at 0xb7531f0c>
<Element 'guid' at 0xb753a22c>
<Element 'guid' at 0xb753a4ec>
<Element 'guid' at 0xb753a7ac>
<Element 'guid' at 0xb753aa6c>
<Element 'guid' at 0xb753ad2c>
Perhaps you want
a.text?If the
guidelement may contain child elements with their own text and you want the text serialization of the whole thing, useetree.tostring(a, method='text').This is a very basic question. Read through the
lxmltutorial on theElementclass.