How to access XML element and get value?

Hello everyone!
how can i get value from xml which has this format :slight_smile:

<applications xmlns="http://st.sss.in/STAB">
<application>
<application_type>APTPISSA</application_type>
	<application_flow_id>1007</application_flow_id>
	<application_status>APST0006</application_status>
	<operator_id>PHR.P248</operator_id>
	<institution_id>1001</institution_id>
	<agent_id>70000011</agent_id>
	<customer_type>ENTTPERS</customer_type>
   <customer>
		<command></command>CMMDEXPR
		<customer_number>998563</customer_number>
		<contract>
			<command></command>CMMDEXPR
			<contract_number></contract_number>
			<card id="card_1">
				<command></command>CMMDEXRE
                <card_number>418240****4004</card_number>
			</card>
		</contract>
	</customer>
	</application>
	
<application>
<application_type>APTPISSA</application_type>
	<application_flow_id>1007</application_flow_id>
	<application_status>APST0006</application_status>
	<operator_id>PHR.P248</operator_id>
	<institution_id>1001</institution_id>
	<agent_id>70000011</agent_id>
	<customer_type>ENTTPERS</customer_type>
   <customer>
		<command></command>CMMDEXPR
		<customer_number>407766</customer_number>
		<contract>
			<command></command>CMMDEXPR
			<contract_number>100000081625</contract_number>
			<card id="card_1">
				<command></command>CMMDEXRE
                <card_number>41824066006003445</card_number>
			</card>
		</contract>
	</customer>
	</application>
	
<application>
<application_type>APTPISSA</application_type>
	<application_flow_id>1007</application_flow_id>
	<application_status>APST0006</application_status>
	<operator_id>PHR.P248</operator_id>
	<institution_id>1001</institution_id>
	<agent_id>70000011</agent_id>
	<customer_type>ENTTPERS</customer_type>
   <customer>
		<command></command>CMMDEXPR
		<customer_number>816941</customer_number>
		<contract>
			<command></command>CMMDEXPR
			<contract_number>100000132450</contract_number>
			<card id="card_1">
				<command></command>CMMDEXRE
                <card_number>41824066014435099</card_number>
			</card>
		</contract>
	</customer>
	</application>
	
<application>
</applications>

All i want is to grab “Customer number” & “Card Number” .

Thanks in advance.

Hi @Prabin_Chand

Checkout this

Regards
Sudharsan

My root element has attribute.
i am not able to do it as shown in video.

Have you checked the thread above ? @Prabin_Chand

Also check this

Regards
Sudharsan

yes i did watched this video too

You need to handle the XML Namespaces:
XML Extraction - Handling Namespaces (Tableau, Soap, OASIS types) - Help / Community - UiPath Community Forum

I saw your post. but it’s little confusing.
How can i do that in my scenario ?
i’am new to UiPath

As described in the above link we check straightforward element name and possible xml namespace parts by:

grafik

so we do have and can creatre the document namespace by:
grafik

We assume that you want to retrieve all Customer numbers / Card numbers

So we do loop over all application elements and then retrieve the Customer/Card numbers

For a first start help have a look here:


Typeargument of the for each activity is set to XElement
Logs:
grafik

Statements:

xnsDefault = xDoc.root.name.Namespace
item in xDoc.Root.Descendants(xnsDefault + "application")
item.Descendants(xnsDefault + "customer_number").First().value
item.Descendants(xnsDefault + "card_number").First().value

Hi @Prabin_Chand

May this help you: How To Extract The Data From A XML file – In UiPath – ExcelCult

Regards
Mohini
Happy Automation…!!!