-1

I have an XML File with this characteristics:

   <Root>
    <Example>
     <Address> Sesame Street </Address>
     <Address> New York US </Address>
    </Example>
    <Example>
     <Address> Nairobi KE</Address>
    </Example>
   </Root>

I want to extract always the second tag (New York US) or the first one if its only one tag. But on UiPath when i try to extract (with Execute XPath activity), it always returns the first one. Any suggestion on how can i extract the second one or the first if its the only one?

Forensic_07
  • 1,125
  • 1
  • 6
  • 10

1 Answers1

0

My understanding is you always want the last Address element in an Example, which can be accomplished by using the XPath function last() in the predicate.

//Address[last()]

This selects both the "New York US" and "Nairobi KE" elements.

I'm a bit unclear on the question, but if your intent is to only extract "New York US", you can specify that you only want the last Address in the first Example.

//Example[1]/Address[last()]

Forensic_07
  • 1,125
  • 1
  • 6
  • 10