Link to home
Start Free TrialLog in
Avatar of tmonteit
tmonteitFlag for Afghanistan

asked on

Python XML issue

I'm having difficulty parsing an xml file and then searching the tree with xpath.
What am I doing wrong here?

2 from xml.etree.ElementTree import ElementTree
    3  tree = ElementTree()
    4  myTree = tree.parse('myFile.xml')
    5  root=myTree.getroot()
    6
    7     #error1: AttributeError: _ElementInterface instance has no attribute '      > getroot'
    8
    9  for node in myTree.findall('/*/path'):
   10
   11     #error2: SyntaxError: cannot use absolute path on element
   12
ASKER CERTIFIED SOLUTION
Avatar of pepr
pepr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pepr
pepr

I do recommend to read the Chapter 12. XML from the "Dive Into Python 3" by Mark Pilgrim.  It uses Python 3, but you can apply it also to Python 2.x.
Sorry, I forgot to include the URL: http://diveintopython3.org/xml.html