I want to traverse an xml file and at each node retain the full path from the parent to that node ie. if we have:
<a> <b att="atttag" content="b"> this is node b </b> <c> this is node c <d> this is node d </d> </c> <e> this is node e </e> </a> ... then require: <a> <a><b att="atttag" content="b"> this is node b <a><c> this is node c <a><c><d> this is node d <a><e> this is node e I found this code on the Comp.Lang.Python list but it doesn't retain the full path. import xml.etree.ElementTree as ET tree = ET.parse(xmlfile) def traverse(node): for c in node.getchildren(): print c.tag, ':', c.text traverse(c) root = tree.getroot() traverse(root) Any ideas how to do this? Thanks Dinesh
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor