I've got an XML file that looks like this:
<routingTable>
<router>
<id>1</id>
<ip>1.1.1.1</ip>
<nexthop>1.1.1.2</nexthop>
</router>
<router>
<id>2</id>
<ip>2.2.2.1</ip>
<nexthop>2.2.2.2</nexthop>
</router>
</routingTable>
With possibly more than two router entries as time goes on. What I would like to do, is take each router instance and throw it into a dictionary. This way, I can query each one by ID, IP, or nexthop. I've been playing with xml.etree.ElementTree but no luck so far. Tried different things with forloops which will print each of the tag values, but I cant really reference them later. ie:
from xml.etree import ElementTree as ET
routetable = ET.parse('RoutingTable.xml')
for route in routetable.iter():
print route.text