Find all nodes from XML using cElementTree
2 answers
You can use XPath paths in findall method:
Version 1.2 supports simple element layout paths. In its simplest form, a location path is one or more tag names separated by a slash (/).
You can also use an asterisk (*) instead of a tag name to match all elements at that level. For example, * / subtag returns all grandchildren's subtitles.
An empty tag (//) is used to search through all levels of the tree, under the current level. An empty tag must always be followed by the tag name or an asterisk.
etree.findall('.//*')
+2
source to share