Given XML that looks something like this
<FirstChild Orientation="Vertical">
<SecondChild>Some text</SecondChild>
</FirstChild>
and a binding that is using
XPath="child::node()"
I get output that looks like this
I don't want the text to appear in the tree
I tried using not
like
XPath="child::node()[not(text())]"
as well as many variations, but haven't been able to nail it.
Anyone know how select all nodes except text nodes?
BTW, I do not want to exclude comments, only text.
The child axis indicates the children of the context node. If an XPath expression does not specify an axis, the child axis is understood by default. Since only the root node or element nodes have children, any other use will select nothing.
Child nodes include elements, text and comments. Note: The NodeList being live means that its content is changed each time new children are added or removed. The items in the collection of nodes are objects, not strings. To get data from node objects, use their properties.
The textContent property of the Node interface represents the text content of the node and its descendants. Note: textContent and HTMLElement.
Your XPath expression excludes all child nodes which contain a text node.
child::node()[not(text())]
Exclude nodes that are a text node themselves:
child::node()[not(self::text())]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With