# Looping XML Elements

**URL:** <https://forum.uipath.com/t/looping-xml-elements/771648>\
**Category:** Activities\
**Tags:** question, webapi, activities\
**Created:** [October 5, 2024, 5:17pm UTC](https://forum.uipath.com/t/looping-xml-elements/771648 "2024-10-05T17:17:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![devasaiprasad\_K](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/devasaiprasad_k/32/512548_2.png) [@devasaiprasad\_K](https://forum.uipath.com/u/devasaiprasad_K)\
**Post date:** [October 5, 2024, 5:17pm UTC](https://forum.uipath.com/t/looping-xml-elements/771648/1 "2024-10-05T17:17:32Z")

</div>

![WhatsApp Image 2024-10-05 at 22.28.05_40fb4c49](https://global.discourse-cdn.com/uipath/original/4X/8/b/5/8b599b0147cb0dae4298d8a8cee8a06d666157e7.jpeg)

The no.of occurances of specialitycode and specialtyName might not be defined, sometimes it occurs only once, sometime twice, but we need to capture all the occurrances

---

<div class="post-metadata">

**Author:** ![ashokkarale](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ashokkarale/32/474400_2.png) [@ashokkarale](https://forum.uipath.com/u/ashokkarale)\
**Post date:** [October 5, 2024, 5:27pm UTC](https://forum.uipath.com/t/looping-xml-elements/771648/2 "2024-10-05T17:27:18Z")

</div>

@devasaiprasad_K,

Refer this thread for the solution.

> [@XML deserialize](https://forum.uipath.com/t/xml-deserialize/277659):
>
> Hi all, I have some XML (listed below), from which I need to extract some attribute values. The element from which I need to extract is shown below, and I need the values from the “value” attributes of the generic:ObsDimension and generic:ObsValue elements. \<generic:Obs\> \<generic:ObsDimension value="2018-12-20"/\> \<generic:ObsValue value="7.4672"/\> \<generic:Attributes\> \<generic:Value id="OBS\_STATUS" value="A"/\> \<generic:Value id="OBS\_CONF" value="F"/\> \</generic:Attributes\> \</ge…

---

<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:** [October 6, 2024, 2:14am UTC](https://forum.uipath.com/t/looping-xml-elements/771648/3 "2024-10-06T02:14:27Z")

</div>

@devasaiprasad_K

I hope this explanation would help

> [@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\</…

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:** [October 6, 2024, 2:34pm UTC](https://forum.uipath.com/t/looping-xml-elements/771648/4 "2024-10-06T14:34:31Z")

</div>

we suggest the following:

Analyze the XML Namespaces as described here:

> [@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\</…

then loop over all speciality elements and process the code and name

xnsDefault | XNamespace Variable

For each activity | TypeArgument: XElement |  
`item in xDoc.Root.Descendants(xnsDefault + "specialty")`

- log message: `item.Element(xnsDefault + "specialtyCode").Value`
- log message: `item.Element(xnsDefault + "specialtyName").Value`

---

<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:** [October 8, 2024, 10:02am UTC](https://forum.uipath.com/t/looping-xml-elements/771648/5 "2024-10-08T10:02:13Z")

</div>

please check the answers and lets get finalized the topic by  
[Forum FAQ - How to mark a post as a solution - News / Tutorials - UiPath Community Forum](https://forum.uipath.com/t/forum-faq-how-to-mark-a-post-as-a-solution/338723)
