> xml = """
>
>
>
>
>
>
>
>
>
>
>
>
>
> """
>
> import xml.etree.ElementTree as etree
>
> tree = etree.fromstring(xml)
>
> def walk(elem, path, token):
> path += (elem,)
> if token in elem.attrib.values():
> yield path
> for child i
Thank you Peter and Dieter, will give those thoughts a try and report back.
--
http://mail.python.org/mailman/listinfo/python-list
Jason Friedman writes:
> I have XML which looks like:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> The "Property X" string appears twice times and I want to output the "path"
> that leads to all such appearances.
You could use "lxml" and its "xpath" support.
Jason Friedman wrote:
> I have XML which looks like:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> The "Property X" string appears twice times and I want to output the
> "path"
> that leads to all such appearances. In this case the output would be:
>
> LEVE
I have XML which looks like:
The "Property X" string appears twice times and I want to output the "path"
that leads to all such appearances. In this case the output would be:
LEVEL_1 {}, LEVEL_2 {"ATTR": "hello"}, ATTRIBUTE {"NAME": "Property X",