I’m using XPath with the lxml module of Python, and have the following xml code.
<library>
<section1>
<book>
<title>Harry Potter</title>
<author>J.K. Rowling</author>
</book>
</section1>
<section2>
<book>
<title>Sapiens</title>
<author>Yuval Noah Harari</author>
</book>
</section2>
</library>
Say I have some title
nodes got from lxml’s .xpath
method. How do I check if some of them has a section1
ancestor which is a child of the library
root node?