Thursday, October 10, 2024

OIC - "Using local-name() in XPath to Retrieve XML Data Without Namespace Prefix"

Use case: 

In this scenario, we will demonstrate how to retrieve the value of the ErrMsg field in XML using the local-name() XPath function, bypassing the need for a namespace prefix.

The following response was received from an endpoint where the namespace prefix is missing. Our objective is to retrieve the value of the ErrMsg field for further post processing logic:

<enb:ImportDataResponse xmlns:enb="enablon">

    <Response>

        <RowCount>2</RowCount>

        <RowSuc>2</RowSuc>

        <ErrMsg />

    </Response>

</enb:ImportDataResponse>


Solution:

We need to use xslt xpath function: local-name() as below:

$Invoke_SkillsAssessment_ImportData_Enablon//*[local-name()='Response']/*[local-name()='ErrMsg']


No comments:

Post a Comment

Featured Post

11g to 12c OSB projects migration points

1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper:   File⇾Import⇾Service Bus Resources⇾ Se...