jeudi 21 juillet 2016

Python lxml getpath error

I'm trying to get a full list of xpaths from a device config in xml.

When I run it though I get AttributeError: 'Element' object has no attribute 'getpath'

Code is just a few lines

import xml.etree.ElementTree
import os
from lxml import etree

file1 = 'C:Userstest1Desktoptest.xml'
file1_path = file1.replace('\','/')


e = xml.etree.ElementTree.parse(file1_path).getroot()

for entry in e.iter():
    print e.getpath(entry)

anyone come across this before ?

Thanks

Richie

Aucun commentaire:

Enregistrer un commentaire