Using XPath for locating elements in HTML

We have our own way of introducing (explaining) XPath to the trainees in our public training programs.

When A=B and B=C. We ask the students what can be derived from these expressions. Immediately the students reply with A=C, even before the question is asked.

Then we give following two statements

  • XPath is for  locating the elements or nodes  in XML documents
  • XML and HTML has similar syntax (HTML is a subset of  XML)

Hence XPath can be used to locate elements in HTML pages (web pages).