Monday, 15 March 2010

python - Find Parent of specific Child -


Text after "

Is this package possible with xml.etree to find a child's parents? For example:

I search for the object "elements" that include the child "continuous specification".

"itemprop =" text ">

You can use the <.> .us elements [constant specification] XPath expression , example:

  as imported ET data xml.etree.ElementTree = "" "& lt;? Xml version =" 1.0 "encoding =" ISO-8859-1 "& gt; root & gt; & lt; element & gt; & lt; constant specification & gt; & lt; / constant specification & gt; & lt; / element & gt; & lt; ; Element & gt; & lt; data-specifications & gt; & lt; / data-specifications & gt; & lt; / element & gt; & lt; / root & gt; "" "root = et.fromstring ) Print Root (Find '.applications [constant-specification]')  

No comments:

Post a Comment