Reputation: 3
I have this xml document: " : " is the separator.
xml = """
<a>
<b> 1,2,3 : 4,5,6 : 7,8,9 : 10,11,12 </b>
</a>
"""
How can I get the middle number in the last pair (i.e., 11) by using Xpath 1.0
I used the combination of substring-before and substring-after, but the result didn't work out as I wanted.
Update: Sometimes, it's not always only 4 pairs, sometimes only 1 pair, or 2 pairs, but maximum it can be up to 10 pairs. So all I want is to always get the middle number of the last pair out. How can I extract it?
Thank you for any ideas.
Upvotes: 0
Views: 32
Reputation: 4834
In 1.0 you would need a larger xpath like this:
substring-before(
substring-after(
substring-after(
substring-after(
substring-after(/a/b,':')
,':')
,':')
,',')
,',')
Upvotes: 0