# Reading xml - xmlDocument

**URL:** <https://forum.uipath.com/t/reading-xml-xmldocument/563495>\
**Category:** Activities\
**Tags:** question, system, activities\
**Created:** [July 14, 2023, 4:16pm UTC](https://forum.uipath.com/t/reading-xml-xmldocument/563495 "2023-07-14T16:16:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juan\_Esteban\_Valencia](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/juan_esteban_valencia/32/145001_2.png) [@Juan\_Esteban\_Valencia](https://forum.uipath.com/u/Juan_Esteban_Valencia)\
**Post date:** [July 14, 2023, 4:16pm UTC](https://forum.uipath.com/t/reading-xml-xmldocument/563495/1 "2023-07-14T16:16:49Z")

</div>

I am having a problem when trying to read an xml through invoke code, I have the following script

DocumentXML = New System.Xml.XmlDocument()  
DocumentXML.Load(Path)

But it generates the following error  
Invoke Code: No compiled code to run  
error BC31051: Namespace or type ‘System.Xml.XPath’ has already been imported. At line -2

I don’t quite understand what I should do

---

<div class="post-metadata">

**Author:** ![lrtetala](https://avatars.discourse-cdn.com/v4/letter/l/e19b73/32.png) [@lrtetala](https://forum.uipath.com/u/lrtetala)\
**Post date:** [July 14, 2023, 4:22pm UTC](https://forum.uipath.com/t/reading-xml-xmldocument/563495/3 "2023-07-14T16:22:25Z")

</div>

Hi @Juan_Esteban_Valencia

Remove the import statement for ‘System.Xml.XPath’:

- Open the Invoke Code activity.
- Check if there is an import statement for ‘System.Xml.XPath’ at the beginning of the code.
- If present, remove the import statement for ‘System.Xml.XPath’.

---

<div class="post-metadata">

**Author:** ![Juan\_Esteban\_Valencia](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/juan_esteban_valencia/32/145001_2.png) [@Juan\_Esteban\_Valencia](https://forum.uipath.com/u/Juan_Esteban_Valencia)\
**Post date:** [July 14, 2023, 4:26pm UTC](https://forum.uipath.com/t/reading-xml-xmldocument/563495/4 "2023-07-14T16:26:59Z")

</div>

Hello, thanks for the answer, but reviewing the invoke code, there are only these two lines  
DocumentXML = New System.Xml.XmlDocument()  
DocumentXML.Load(Path)  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/1/1/c/11c9d584c8aba9cad2a9c11337828c5c3be34feb.png)

---

<div class="post-metadata">

**Author:** ![raja.arslankhan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/raja.arslankhan/32/463418_2.png) [@raja.arslankhan](https://forum.uipath.com/u/raja.arslankhan)\
**Post date:** [July 14, 2023, 5:00pm UTC](https://forum.uipath.com/t/reading-xml-xmldocument/563495/5 "2023-07-14T17:00:05Z")

</div>

@Juan_Esteban_Valencia Can you show me your variables type

---

<div class="post-metadata">

**Author:** ![raja.arslankhan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/raja.arslankhan/32/463418_2.png) [@raja.arslankhan](https://forum.uipath.com/u/raja.arslankhan)\
**Post date:** [July 14, 2023, 5:00pm UTC](https://forum.uipath.com/t/reading-xml-xmldocument/563495/6 "2023-07-14T17:00:44Z")

</div>

@Juan_Esteban_Valencia  
Use a different script activity: Instead of using the Invoke Code activity, you can try using other activities specifically designed for XML processing, such as the Read Text File and Deserialize XML activities. These activities provide a more straightforward way to read XML files in UiPath.

---

<div class="post-metadata">

**Author:** ![Juan\_Esteban\_Valencia](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/juan_esteban_valencia/32/145001_2.png) [@Juan\_Esteban\_Valencia](https://forum.uipath.com/u/Juan_Esteban_Valencia)\
**Post date:** [July 14, 2023, 5:02pm UTC](https://forum.uipath.com/t/reading-xml-xmldocument/563495/7 "2023-07-14T17:02:09Z")

</div>

Of course, look at them

 ![image](https://global.discourse-cdn.com/uipath/original/4X/7/c/4/7c433d53c185623ba9863b596ddb8a92add7b785.png)

---

<div class="post-metadata">

**Author:** ![Juan\_Esteban\_Valencia](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/juan_esteban_valencia/32/145001_2.png) [@Juan\_Esteban\_Valencia](https://forum.uipath.com/u/Juan_Esteban_Valencia)\
**Post date:** [July 14, 2023, 5:04pm UTC](https://forum.uipath.com/t/reading-xml-xmldocument/563495/8 "2023-07-14T17:04:58Z")

</div>

what happens is that the output variable should be XmlDocument, and the UiPath activities give me an output variable XDocument

---

<div class="post-metadata">

**Author:** ![Juan\_Esteban\_Valencia](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/juan_esteban_valencia/32/145001_2.png) [@Juan\_Esteban\_Valencia](https://forum.uipath.com/u/Juan_Esteban_Valencia)\
**Post date:** [July 14, 2023, 9:23pm UTC](https://forum.uipath.com/t/reading-xml-xmldocument/563495/9 "2023-07-14T21:23:30Z")

</div>

Hi guys, I already managed to detect the problem, in the sequence where the invoke code was hosted, for a strange reason when opening it with notepad++ I detected that the line \<x:String\>System.Xml.XPath\</x:String\> was repeated , what I did was delete one, save the file and run the project again  
It worked!

Thank you very much for everyone’s collaboration  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/0/5/e/05eb1a70afb4a06c365ed48f6a6a8d1a25af2614.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:** [July 17, 2023, 9:23pm UTC](https://forum.uipath.com/t/reading-xml-xmldocument/563495/10 "2023-07-17T21:23:34Z")

</div>

Closed on July 17, 2023, 9:23pm UTC

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