XML file issue


#1

Hi!

I have an issue with reading the XML file in UiPath. UiPath is unable to read XML when 2nd attribute is present in the beginning of the XML. Please find attached XAML workflow and two XML files. First file: OK - is working because second attribute is deleted, second file: NOT OK - is not working because of the second attribute. Please find also attached screenshot of the second attribute. How can I read the NOT OK XML file in UiPath?

Thank you in advance.

Tomas

XML test.xaml (11.3 KB)
test_OK.xml (7.0 KB)
test_NOT_OK.xml (7.1 KB)


#2

@Tomas, Probably you can use this Regex Pattern to replace the yellow highlighted text.

After reading the text, use this in assign activity. (Import System.text.RegularExpressions namespace )

test = Regex.Replace(test,"xmlns\s*=\s*""([^""]*)\""","")

After this you can deserialize.

Regards,
Dom :slight_smile:


#3

Thank you Dominic. I used Replace activity and removed the highlighted text.

Tomas :slight_smile:


#4

It seems you found a solution that works for you, but in case someone runs into a similar problem and can’t or doesn’t want to modify the original XML, it’s possible to access elements using the XmlDocument class and XPath expressions: GetSupplierNameFromXML.zip (4.2 KB)
The important point is the use of the default namespace.