I have XML like this:
<?xml version="1.0" ?>
<iq id="123" to="test" type="result">
<query xmlns="jabber:iq:roster">
<item jid="foo" subscription="both"/>
<item jid="bar" subscription="both"/>
</query>
</iq>
And I would like to parse jid from item into array. I thought something like this would work
import xml.etree.ElementTree as ET
myarr = []
xml = '<?xml version="1.0" ?><iq id="123" to="test" type="result"><query xmlns="jabber:iq:roster"><item jid="foo" subscription="both"/><item jid="bar" subscription="both"/></query></iq>'
root = ET.fromstring(xml)
for item in root.findall('query'):
t = item.get('jid')
myarr.append(t)
print (t)