Reputation: 4356
I think the answer is "no" but I'll ask anyway. Can you find the last occurrence of a newline in text node using XPath 1.0?
E.g. Given the following XML I want to find the last newline (immediately after "second") in order to get the text "third".
<element> first
second
third </element>
If I knew the position of the last newline it would be trivial to get the text after it. I don't actually want to return the value, just test against it.
As far as I can tell XPath 1.0 doesn't have any of:
Any of the above would be enough to solve this problem!
Upvotes: 1
Views: 179
Reputation: 338376
Can you find the last occurrence of a newline in text node using XPath 1.0?
No. XPath generally has not been designed to do string processing.
Of course in XPath 2.0 you can do it by tokenizing the input into sequence and then getting the last element from that sequence. But strictly speaking that does not qualify as text processing, it's sequence handling. In other words, it won't actually give you the position of that last newline character either.
with XPath 1.0 you will have to do this bit of work in the host language.
Upvotes: 2