Monthly Archives: January 2021

XPath cheats

Get the child element nodes of a book node (without comment nodes and text nodes)

//book/*

Get the child elements, text and comment nodes of a book node

//book/*|text()|comment()

The following XPath queries return the same nodes:

$xpath->query("./../bookstore", $contextNode)
$xpath->query("../bookstore", $contextNode);