Hi everyone,
Sorry to as a -users question on a -dev mailing-list, but I don't see
a -users resource for lxml. If one exists, I'd be happy to head over
there.
I have an XML document from a network device that I want to pull into
my python code. The example document I'm working with is attached as
vlan.xml.
I find the results of this to be utterly perplexing:
>>> import lxml.etree as ET
>>> vtree = ET.parse("vlan.xml")
>>> vtree.xpath("vlan")
[]
>>> vtree.xpath("//vlan")
[]
>>> vtree.xpath("rpc-reply")
[]
>>> vtree.xpath("/rpc-reply")
[]
>>> vtree.xpath("*")
[<Element {http://xml.juniper.net/junos/9.2R2/junos-esw}vlan-information at 95a8a04>]
>>> vtree.xpath("vlan-information")
[]
Based on the examples in the lxml XPath documentation, I'd expect the
first to give me a list of Elements, one for each <vlan>...</vlan> in
the file. Second should be the same based on XPath stuff I've read in
Python and XML.
My next two are shots in the dark: <rpc-reply> is the top-level
element, but I can't retrieve it relatively or absolutely.
Next is another shot in the dark, and somehow what I get the element
one under the top-level. Huh? Also, I can't retrieve it by name.
--
Ross Vandegrift
ross(a)kallisti.us
"If the fight gets hot, the songs get hotter. If the going gets tough,
the songs get tougher."
--Woody Guthrie