9.7. A Syntax for Tree Processing with xgrep
So far so good. We have the beginnings of a Python data structure for loading arbitrary XML files into fully navigable data structures. We can carry over all the existing xgrep syntax and add a collection of optional qualifiers. The presence of one of these qualifiers can be used to cause xgrep to work in tree mode.
--parent Match if parent element has the specified element type name
--ancestor Match if list of ancestors contains the specified element type name
--child Match if a child of the matching element has the specified element type name
--descendant Match if a descendant of the matching element has the specified element type name
--sibling Match if a sibling of the matching element has the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access