code_junkie

ElementTree XPath - Select Element based on attribute [closed]

Nov 11th, 2011
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. <root>
  2. <target name="1">
  3. <a></a>
  4. <b></b>
  5. </target>
  6. <target name="2">
  7. <a></a>
  8. <b></b>
  9. </target>
  10. </root>
  11.  
  12. def parse(document):
  13. root = et.parse(document)
  14. for target in root.findall("//target[@name='a']"):
  15. print target._children
  16.  
  17. expected path separator ([)
Add Comment
Please, Sign In to add comment