I am new to XPath so please bear with me. Basic question.
I want to select text, including the elements as well. Example input below:
<node1>
<node2>
<node3>A1</node3>
<node3>A2</node3>
<node3>A3</node3>
<node3>A4</node3>
</node2>
</node1>
I wish to copy the content of node 2 including the tags, which is:
<node2>
<node3>A1</node3>
<node3>A2</node3>
<node3>A3</node3>
<node3>A4</node3>
</node2>
However, if I use the XPath /node1/node2/, I only get values A1 A2 A3 A4 (not the node2 and node3 tags).
The xpath
/node1/node2should return a list ofnodes. Eachnode, depending on what language you are using contains attributes such asnodeNameornodeValuethat you could use to access both the contained text and the name of the tag.