I would like to know what //* means in an xpath expression because I have two expression
//*[A or B]
and
//* [count(descendant::*)=1]
so I don't know what these expressions do.
I would like to know what //* means in an xpath expression because I have two expression
//*[A or B]
and
//* [count(descendant::*)=1]
so I don't know what these expressions do.
// means everywhere in the tree (starting from the root node and going any levels down). It 's different to / which starts at the root node but then operates on the next immediate level.
* is for an arbitrary element (opposed to @ which would be an attribute).
Things inside [ and ] are a condition. In your cases, the condition [A or B] is whether there's a child element A or a child element B. The condition count(descendant::*)=1 means that there is only one child, grandchild and the like.
// means select all, and * means any element.
So //* means select all elements. Adding the [A or B], also makes sure that the element also has a child element named A or B.
Adding the count(descendant::*)=1, I believe ensures that the element only has a single descendant with any name.