I am new in the RPA field and for my robot, I need to deserialize a XML file. But I have an error when doing it because UiPath does not handle atomic nodes. I know this because when I use different XML validation websites, the format of my XML is valid.
Here is an exemple of what I am saying:
When I have an empty field, instead of having
<Email></Email>
I have
<Email i:nil ="true" />
Have you ever had this issue and how did you fix it ?
@melanie - atomic nodes are able to be handled fine. I agree it is the namespace issue. Use an assign activity and assign ns1 = "http://www.w3.org/2001/XMLSchema-instance" - the variable type should be system.xml.linq.xnamespace
Now whenever youāre referencing a node or element, you have to include the namespace. So instead of XDocument.Root.Element("Email") you should put XDocument.Root.Element(ns1 + "Email").
You have to do this every time you are referencing elements/nodes by their XName (itās a pain, i know)
I tried some cases.
If input string is the following xml, I got the following exception like yours.
XML(Lack Email element end tag) <?xml version="1.0" ?> <main xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <ProofOfAddressPrintDto> <Email i:nil ="true" > </ProofOfAddressPrintDto> </main>
(Exception)
Deserialize XML: The āEmailā start tag on line 4 position 2 does not match the end tag of āProofOfAddressPrintDtoā. Line 5, position 3.
If input string is the following xml, there is no exception
Yes. In fact, I was cleaning the XML to remove everything between the name of the field (for example here āExampleā) and the ā>ā to be able to access to elements. But when doing it, I made the XML invalid for deserialization. I understand the issue and thanks to all of you for your help. I will try to deserialize the XML in output without cleaning and then access the elements using the correct namespaces and names.