xml - XPath: select text node -
having following xml:
<node>text1<subnode/>text2</node> how select either first or second text node via xpath?
something this:
/node/text()[2] of course doesn't work because it's merged result of every text inside node.
having following xml:
<node>text1<subnode/>text2</node>how select either first or second text node via xpath?
use:
/node/text() this selects text-node children of top element (named "node") of xml document.
/node/text()[1] this selects first text-node child of top element (named "node") of xml document.
/node/text()[2] this selects second text-node child of top element (named "node") of xml document.
/node/text()[someinteger] this selects someinteger-th text-node child of top element (named "node") of xml document. equivalent following xpath expression:
/node/text()[position() = someinteger]
Comments
Post a Comment