# GET Attribute from XML

**URL:** <https://forum.uipath.com/t/get-attribute-from-xml/520948>\
**Category:** Studio\
**Tags:** activities-panel, question, studio, webapi, activities\
**Created:** [February 26, 2023, 5:06am UTC](https://forum.uipath.com/t/get-attribute-from-xml/520948 "2023-02-26T05:06:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Israel\_Silva](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/israel_silva/32/380382_2.png) [@Israel\_Silva](https://forum.uipath.com/u/Israel_Silva)\
**Post date:** [February 26, 2023, 5:06am UTC](https://forum.uipath.com/t/get-attribute-from-xml/520948/1 "2023-02-26T05:06:09Z")

</div>

In the xml below, how to get the data inside the attribute, I’ve tried many ways and I’m not succeeding

[test.xml](https://forum.uipath.com/uploads/short-url/4poAG1IdTkvisIF5k5TxzPn47Jd.xml) (9.8 KB)

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [February 26, 2023, 6:24am UTC](https://forum.uipath.com/t/get-attribute-from-xml/520948/2 "2023-02-26T06:24:40Z")

</div>

@Israel_Silva

Please check this follow the steps

> [@Get xml attribute value and descriptor values](https://forum.uipath.com/t/get-xml-attribute-value-and-descriptor-values/466717/2):
>
> we would like to remind you on the XML Namespace handling similar to your other topics general flow: [grafik] Check and namespace handling: [grafik] Retrieval: [grafik] Getting all WID types: Getting first one’ s value Bank\_Account: [grafik] For the other retrieval just adapt and handle it similar

Cheers

---

<div class="post-metadata">

**Author:** ![Israel\_Silva](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/israel_silva/32/380382_2.png) [@Israel\_Silva](https://forum.uipath.com/u/Israel_Silva)\
**Post date:** [February 26, 2023, 3:02pm UTC](https://forum.uipath.com/t/get-attribute-from-xml/520948/3 "2023-02-26T15:02:33Z")

</div>

Using the mentioned tutorial, I couldn’t find the CNPJ value in the XML, when I try to specify the element, the result is always Null

Cheers!!

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [February 26, 2023, 3:39pm UTC](https://forum.uipath.com/t/get-attribute-from-xml/520948/4 "2023-02-26T15:39:23Z")

</div>

@Israel_Silva  
Kindly note: the provided XML was incomplete we did repair for some prototyping

> [@Israel\_Silva](#):
>
> get the data inside the attribute

> [@Israel\_Silva](#):
>
> CNPJ value

CNPJ is an element

> [@Israel\_Silva](#):
>
> when I try to specify the element, the result is always Null

we dont know the details, what was done

> [@Israel\_Silva](#):
>
> Using the mentioned tutorial, I couldn’t find the CNPJ value in the XM

as discussed: it was checked and setup the default Namespace:

 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/6/e/b/6eb943b4eb4254f0c4ec0a573dde0fbbd2defe26.png)

And when fetching the CNPJ elements the namespace is used:  
 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/2/c/e/2ce394fa9e7d8562cc5b1dd378380998e774d349.png)

So we would recommend to incorporate the namespace handling as well in your modelling

> [@Understanding the 6 Debugging Panels of UiPath in the easiest way possible!](https://forum.uipath.com/t/understanding-the-6-debugging-panels-of-uipath-in-the-easiest-way-possible/353606):
>
> One of the very important topic of UiPath in Debugging is understanding the different debugging panels and when to use which panel during debugging. In this video, we will understand all the 6 debugging panels of UiPath in the easiest way possible. Video Link: [Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - YouTube](https://youtu.be/6x8zVD8VAmo)

> [@XML Extraction - Handling Namespaces (Tableau, Soap, OASIS types)](https://forum.uipath.com/t/xml-extraction-handling-namespaces-tableau-soap-oasis-types/401623/3):
>
> Going ahead Serializing the XML - output: xDoc | DataType: XDocument: [grafik] Checking if we have to handle XML namespaces We do have: [grafik] Checking for some children: [grafik] Defining Namespace Variable bulb In some cases, we can also do: Assign Activity - xnsDefault = xDoc.Root.Name.Namespace Checkin the retrieval [grafik] xDoc.Descendants(xnsDefault + "productVersion") GetDescendants { [\<productVersion build="456" xmlns="http://tableau.com/api"\>123\</…

> [@How to identify the quantity of items in the NFe xml](https://forum.uipath.com/t/how-to-identify-the-quantity-of-items-in-the-nfe-xml/512388/2):
>
> We would recommend to check first if XML Namespaces are to handle: [XML Extraction - Handling Namespaces (Tableau, Soap, OASIS types) - Help / Community - UiPath Community Forum](https://forum.uipath.com/t/xml-extraction-handling-namespaces-tableau-soap-oasis-types/401623/3) Maybe you can share the XML as textfile with us

---

<div class="post-metadata">

**Author:** ![Israel\_Silva](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/israel_silva/32/380382_2.png) [@Israel\_Silva](https://forum.uipath.com/u/Israel_Silva)\
**Post date:** [February 26, 2023, 4:30pm UTC](https://forum.uipath.com/t/get-attribute-from-xml/520948/5 "2023-02-26T16:30:29Z")

</div>

Thank you very much, in this case I need to get the second number, but when I put it in a for each it brings me a whole string:04895728000180

How do I get just the numbers without using regex, how?

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [February 26, 2023, 4:40pm UTC](https://forum.uipath.com/t/get-attribute-from-xml/520948/6 "2023-02-26T16:40:34Z")

</div>

we would loop over the descendants return  
`xDoc.root.Descendants(xnsDefault + "CNPJ").`  
Or  
Access directly the second one  
Or  
catch all values

Find some samples:  
 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/a/f/b/afb52fa6181487461665dd051ea4456c00539eff.png)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [March 1, 2023, 4:40pm UTC](https://forum.uipath.com/t/get-attribute-from-xml/520948/7 "2023-03-01T16:40:37Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
