I have an xml document with multiple nodes that looks something like this:
<Result>
<Url>http://www.mysite.com/Topic/1/</Url>
</Result>
<Result>
<Url>http://www.mysite.com/Topic/2/</Url>
</Result>
<Result>
<Url>http://www.mysite.com/Topic/3/</Url>
</Result>
What I want to do is to retrieve the Topic ID after “Topic/” for all nodes. For the above example I am looking for the values 1,2 and 3. I can think of other ways to do it but I was wondering if there was a way to do it using XPath?
You can use substring-after paired with substring-before to just extract the number
This is the expression
Given your input (I added a root node to make it vaild)
this transform illustrates the result you want
Output
Depending on the context, you should replace
.in the expression above with the path you need to access your node.