I am trying to parse a string in an XML node using an XPath query, which requires me to split the substring and read the remaining value. A substring can have a dynamic number of spaces before and after it before I can get to the value, so it would be useful to have some kind of indexOf function for use in XPath. I am trying to use substring-after, but there is a good chance that XPath 1.0, which according to this post can make it harder. The following is an example of an XML I'm trying to parse:
<root>
<myField> StringToParse 7</myField>
</root>
I am trying to get the value 7 in a string, which is possible with some combination of substrings after and normalization-space. I’m not quite sure that I use it correctly, because no matter what way I try to use it, the result is either a zero value or an entire string, while the substring is not deleted.
How can I return the whole value (the lesser of two evils):
/myField[substring-after(.,'StringToParse')]
which, I hope, would return "7". Can someone tell me that I am wrong in the syntax, or if there is an alternative method that I should use to accomplish what I need?
Thank,
Mike
source
share