0

below is the sample request from target application where i need to parse the xml to find the value for Code element and currency value for the respective country and assign these to a variables to process further logic

 <cal:process  xmlns:cal="http://example.com">
     <cal:input>
        <!--receiving the below xml string as input -->
        <sampledata xmlns="http://123.com">
           <List>
              <countries>
                 <country xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">INDIA</country>
                 <currency xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">INR</currency>
              </countries>
              <countries>
                 <country xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">UK</country>
                 <currency xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">GB</currency>
              </countries>
           </List>
           <Code>CONTRACT</Code>
        </sampledata>
     </cal:input>
  </cal:process>

if anyone has done this earlier, can i please request you to share me the sampe xslt ?

  • I see no "xml string" in the input. In addition, the input is not well-formed XML because the `cal` prefix is not bound to a URI. – michael.hor257k Nov 12 '21 at 13:41
  • @michael.hor257k My mistake ,Updated the request to inlcude namespace. now the document is valid. regarding the xml string as mentioned in the input request comment i will be receiving the data from target application for the input element is given in the request starts from sampledata. I have tried accessing the data using the below xpath Xpath: /cal:process/cal:input/sampledata result: it's says no match found. – Venkatesh Lu Nov 13 '21 at 15:33
  • 1
    Your path `/cal:process/cal:input/sampledata` cannot work because `sampledata` and all its descendant elements are in a namespace - see: https://stackoverflow.com/a/34762628/3016153 – michael.hor257k Nov 13 '21 at 15:38
  • @michael.hor257k Thanks for pointing me into the right direction. I was able to fetch the details by adding the namespace – Venkatesh Lu Nov 15 '21 at 03:54

0 Answers0