Question

I want a code snippet to check if the first child node is a processing instruction or not?

For example :

<caml:Author>
<?PI-start data="processing instruction"?>
<caml:Leg> test data </caml:Leg>
</caml:Author>

In the above example the first child node of caml:Author tag is a processing instruction. How can I find if the first child node is a processing instruction ?

Was it helpful?

Solution

Remembering that you could also get comments or text nodes (the first child node of in your example is a text node), then if caml:Author is my current node, I would use the following to address the children:

  test="(processing-instruction() | *)[1][self::processing-instruction()]"

The result is true if the first of the processing-instruction and element children is a processing-instruction.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top