I have an external xml file that I am loading in my views.py file
def test(request):
url = urllib2.urlopen("http://someurl.com?xml")
dom = minidom.parse(url)
groups = dom.getElementsByTagName("group")
deal_holder = []
# Iterate over each DOM group element:
for group in groups:
# Iterate over each child node
for groupChild in group.childNodes:
deal_holder.append(groupChild)
return render_to_response('folder/test.html', {'deal_holder':deal_holder})
This is what the loaded XML file looks like:
<page>
<site>
<siteid>25550</siteid>
<sitename>
<![CDATA[ Some Text Here ]]>
</sitename>
<sitelink>
http://somelinkehere.com
</sitelink>
<timezone>
<![CDATA[ Pacific Time ]]>
</timezone>
</site>
<groups>
<enablefeaturedgroup>OFF</enablefeaturedgroup>
<group>
<groupid>467246</groupid>
<groupname>
<![CDATA[ Today's Deal ]]>
</groupname>
<groupdescription>
<![CDATA[ ]]>
</groupdescription>
</group>
<group>
<groupid>467247</groupid>
<groupname>
<![CDATA[ Past Deals ]]>
</groupname>
<groupdescription>
<![CDATA[ ]]>
</groupdescription>
</group>
</groups>
</page>
The problem is that all of the examples I've seen use something like what I'm using except that they usually have XML tags that look like this: <weather:forecast day="Wed" date="14 Sep 2011" low="56" high="72" text="AM Clouds/PM Sun" code="30"/> and are able to retrieve the information from stuff like the day="Wed", date="14 Sep 2011", low="56" etc... but the info I want to retrieve is actually between the tags such as <siteid>25550</siteid>
Any advice or info would be greatly appreciated.