I need a one-line XPath 1.0 expression to calculate the length of a node, but excluding text in any child nodes (if they are present).
For instance, the string-length() of
<node>This is text</node>
is 12 (ok), but the string-length() of
<node>This is<any>any text</any> text</node>
<node>This <any>any text</any>is text</node>
is more than 12 (not ok).
I cannot use string-length(//node/text())
, because it takes the first chunk of text inside node
, if there are any child nodes inside node
.