5.5. XML XPATH
Using
lxml
module
5.5.1. Example
print(html.xpath("string()")) # lxml.etree only!
# IrisSetosa
print(html.xpath("//text()")) # lxml.etree only!
# ['Iris', 'Setosa']
5.5.2. Use Case - 1
>>> class XPath:
... def __init__(self, current):
... self.current = current
...
... def __div__(self, other):
... return self.current.xpath(other)
>>>
>>>
>>> XPath(root) / 'Header' / 'Depth' / 'Max'