On Sep 4, 3:09 pm, Terry Brown <[email protected]> wrote:


> w/o xpath, it's somehow search for the element with @id='co_text_holder', and 
> then somehow find its parent.

How about this? ::

import xml.etree.ElementTree as etree
path = r'C:\leo.repo\inkcall\template.svg'
root = etree.parse(path).getroot()
print('='*30)
d = {}
def computeParents(d,e):
    for child in e.getchildren():
        d[child] = e
        computeParents(d,child)

computeParents(d,root)
for key in d.keys():
    print('child: %9s parent: %9s' % (id(key),id(d.get(key))))

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to