XPath allows the following nodes to be selected.

  • Root Node

  • Element Nodes

  • Attribute Nodes

  • Text Nodes [text()]

  • Comment Nodes [comment()]

  • Namespace Nodes

    Should Namespaces be treated as nodes?


    Deprecated since XPath 2.0
  • Processing Instruction Nodes [processing-instruction()]

  • ... any Node [node()]

  • Use the comment() function to match any comment.


    Returns all comments in the document.

  • Use the text() function to match any text nodes.


    Returns the text nodes for the all author elements.

  • Use the processing-instruction() function to match PIs.


    The first XPath returns all the PIs in the document and the second returns all 'xml-stylesheet' PIs.

XPath assumes Entities, DocTypes and CData sections to be normalized before the expression is evaluated.