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

OIC - how can I use XSLT functions to remove leading zeros from numeric and alphanumeric fields?

To remove leading zeros from an numeric field in Oracle Integration Cloud (OIC) using XSLT, you can Use number() Function The number() funct...