[XML-SIG] parsing XML with minidom
Stefan Behnel
stefan_ml at behnel.de
Tue Apr 27 13:35:32 CEST 2010
kimmyaf, 26.04.2010 23:14:
> Stefan Behnel-3 wrote:
>> kimmyaf, 26.04.2010 00:24:
>>> Hello. I've only done a litte bit of parsing with minidom before but I'm
>>> having trouble getting my values out of this xml. I need the latitude and
>>> longitude values in bold.
>>
>> I don't see anything 'bold' in your mail, but your example tells me what
>> data you mean.
>>
>> Here is some untested code using xml.etree.cElementTree:
>>
>> import xml.etree.cElementTree as ET
>> tree = ET.parse("thefile.xml")
>> for tag in tree.getiterator("location"):
>> print tag.findtext("lat"), tag.findtext("lng")
>
> Thanks Stefan. I tried this but it's not getting into the for block for some
> reason.
Maybe the document uses namespace declarations that you forgot to show us?
Stefan
More information about the XML-SIG
mailing list