The processing-instruction() node test retrieves a set of processing-instruction (PI) nodes, which are children and siblings of element nodes or are children of the root node. Here's an XML document with a single processing instruction:
<?xml version="1.0" encoding="ISO-8859-1"?> <Material>Leather <?HandleThis how="somehow" ?> <Product>Leather Seats</Product> <Quantity>20</Quantity> </Material><?HandleThat how="another way" ?>
The next expression returns the contents of the instruction, including the spaces that follow the phrase how="somehow".
/Material/processing-instruction('HandleThis')
The node test can identify a processing-instruction node by specifying a PI target, such as HandleThis, but the test is also valid without specifying a PI target. The next expression returns two nodes.
count(/descendant::processing-instruction())
The XML declaration statement (which starts with <?xml) is not a processing instruction and is not available to an XPath expression.