Q: Getting Xpath from plain text Im trying to get xpath from text instead of a URL.  But i keep getting the error "AttributeError: 'HtmlElement' object has no attribute 'XPath'"
see code below.
from lxml import html

var ='''<html lang="en">
  <head>
    <title>Selecting content on a web page with XPath</title>
  </head>
  <body>
     This is the body
  </body>
</html>
'''

tree = html.fromstring(var)

body = tree.XPath('//*/body')

print(body)



A: It has been 15 years since I last used Python, but as far as I can tell, it is a case-sensitive language, and the xpath method is all lowercase.
So try this:
body = tree.xpath('//*/body')

