I am going through tutorials on ElementList in Python with this file and all the operations work fine:
<?xml version="1.0"?>
<data>
    <country name="Liechtenstein">
        <rank>1</rank>
        <year>2008</year>
        <gdppc>141100</gdppc>
        <neighbor name="Austria" direction="E"/>
        <neighbor name="Switzerland" direction="W"/>
    </country>
    <country name="Singapore">
        <rank>4</rank>
        <year>2011</year>
        <gdppc>59900</gdppc>
        <neighbor name="Malaysia" direction="N"/>
    </country>
    <country name="Panama">
        <rank>68</rank>
        <year>2011</year>
        <gdppc>13600</gdppc>
        <neighbor name="Costa Rica" direction="W"/>
        <neighbor name="Colombia" direction="E"/>
    </country>
</data>
I can find any bit of data I want in this, with the root being data. I got this here: http://docs.python.org/2/library/xml.etree.elementtree.html
Eg:
import xml.etree.ElementTree as ET
tree = ET.parse('test.xml')
root = tree.getroot()
for child in root:
    print child.tag
    print child.attrib
This would give:
country
{'name': 'Liechtenstein'}
country
{'name': 'Singapore'}
country
{'name': 'Panama'}
However in the xml file I have to read and use I can't seem to get any of the data that I want. Here is the file: http://pastebin.com/b5bwrSFU
If I run the same code I get:
{http://clish.sourceforge.net/XMLSchema}VIEW
{'depth': '1', 'prompt': '${KHOSTNAME}(config-if)# ', 'name': 'configure-range-view'}
{http://clish.sourceforge.net/XMLSchema}VIEW
{'name': 'configure-view'}
I can't seem to get any data from below configure-view, any ideas?
I also tried:
for neighbor in root.iter('VIEW'):
    print neighbor.attrib
for i in root.findall('COMMAND'):
    print i
    rank = i.find('help').text
    name = i.get('name')
    print name, rank
and changing the root:
root = ET.Element("COMMAND")
Nothing gets printed out.
