on 2022 May 17 11:58 AM
Hello Experts,
I am trying to filter records based on the 2 digit country code(ISO_3166-1_Alpha-2_Code). I want to filter the records of workers working in country India(IN). Below is the xml source code.
<wd:Get_Workers_Response xmlns:wd="urn:com.workday/bsvc" wd:version="v32.0">
<wd:Worker>
<wd:Employment_Data>
<wd:Home_Country_Reference>
<wd:ID wd:type="ISO_3166-1_Alpha-2_Code">AR</wd:ID>
<wd:ID wd:type="ISO_3166-1_Alpha-3_Code">ARG</wd:ID>
</wd:Home_Country_Reference>
</wd:Employment_Data>
<wd:Personal_Data>
<wd:Name_Data>
<wd:First_Name>Rohit</wd:First_Name>
<wd:Last_Name>Singh</wd:Last_Name>
</wd:Name_Data>
</wd:Personal_Data>
</wd:Worker>
<wd:Worker>
<wd:Employment_Data>
<wd:Home_Country_Reference>
<wd:ID wd:type="ISO_3166-1_Alpha-2_Code">IN</wd:ID>
<wd:ID wd:type="ISO_3166-1_Alpha-3_Code">IND</wd:ID>
</wd:Home_Country_Reference>
</wd:Employment_Data>
<wd:Personal_Data>
<wd:Name_Data>
<wd:First_Name>Shivam</wd:First_Name>
<wd:Last_Name>Dubey</wd:Last_Name>
</wd:Name_Data>
</wd:Personal_Data>
</wd:Worker>
</wd:Get_Workers_Response>
I have used below Xpath expression.
//wd:Employment_Data[wd:Home_Country_Reference/wd:ID = 'IN']
which gives me below output
Element='<wd:Employment_Data xmlns:wd="urn:com.workday/bsvc">
<wd:Home_Country_Reference>
<wd:ID wd:type="ISO_3166-1_Alpha-2_Code">IN</wd:ID>
<wd:ID wd:type="ISO_3166-1_Alpha-3_Code">IND</wd:ID>
</wd:Home_Country_Reference>
</wd:Employment_Data>'
Output of this Xpath expr. doesn't contain Personal_Data node. Is it possible to filter records based on country(IN) and have both nodes (Employment_Data and Personal_Data) in the output by using Xpath expressions?? Or do we have to use XSLT for this transformation.
Expected Output.
<wd:Get_Workers_Response xmlns:wd="urn:com.workday/bsvc" wd:version="v32.0">
<wd:Employment_Data>
<wd:Home_Country_Reference>
<wd:ID wd:type="ISO_3166-1_Alpha-2_Code">IN</wd:ID>
<wd:ID wd:type="ISO_3166-1_Alpha-3_Code">IND</wd:ID>
</wd:Home_Country_Reference>
</wd:Employment_Data>
<wd:Personal_Data>
<wd:Name_Data>
<wd:First_Name>Shivam</wd:First_Name>
<wd:Last_Name>Dubey</wd:Last_Name>
</wd:Name_Data>
</wd:Personal_Data>
</wd:Worker>
</wd:Get_Workers_Response>
Request clarification before answering.
Hi Mohit,
Try with below-
/wd:Get_Workers_Response [wd:Worker/wd:Employment_Data[wd:Home_Country_Reference/wd:ID = 'IN']]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
75 | |
30 | |
9 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.