0

I have an XML, where I have Multiple wd:type="Supplier_Connection_ID" nodes but always i need the last one.

How to write X path If we have same nodes in one XML. Below are my nodes from XML. Always I need the second node if there are 2 nodes ,If there are 100 same nodes I need the 100th node to be represent in X path.

> 
>     >  <wd:Supplier_Connection_Reference>
>     >                                 <wd:ID wd:type="WID">1f09b504c3f610f442c94f852fc1f695</wd:ID> 
>     >  <wd:ID
>     > wd:type="Supplier_Connection_ID">SUPPLIER_CONNECTION-6-1393</wd:ID>
>     >                             </wd:Supplier_Connection_Reference>
> 
> 

> 
>      <wd:Supplier_Connection_Reference>
>                                     <wd:ID wd:type="WID">1f09b504c3f610f44318940ccbe2f721</wd:ID>
>                                     <wd:ID wd:type="Supplier_Connection_ID">SUPPLIER_CONNECTION-6-1394</wd:ID>
>                                 </wd:Supplier_Connection_Reference>
> 
> 

Thanks Sam.

  • 1
    Possible duplicate of [XSLT getting last element](http://stackoverflow.com/questions/1459132/xslt-getting-last-element) – ShockwaveNN Jan 13 '17 at 15:34

1 Answers1

0

What strikes me is that the WID value in your two sample snippets is not identical.

Thus I can't understand whether your file contains data of your transactions with one single supplier or whether it contains data of your transactions with various suppliers.

If you want to navigate to very last element of the whole file you could simply use "//wd:Supplier_Connection_Reference[last()]/wd:ID[@ wd:type="Supplier_Connection_ID"]".

If you keep the data for several suppliers in the same file, your XPath should contain a filtering predicate for the ID of a specific supplier.

  • Yes, its with one single supplier but that supplier have multiple "Supplier connection ID'S" , where I need to get the last value by writing Xpath. – Samudrala Uday Jan 13 '17 at 16:21