UiPath does not handle atomic nodes (XML)

Hello everyone,

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 ?

Thanks in advance for your help

Hi,

I suppose this is namespace matter.
Do you declare namespace “i” in advance?

If not, the following can be deserialized without error, for example.
<Email xmlns:i ="http://www.example.org" i:nil ="true" />

Because “:” is special character in XML attribute

Regards,

Thanks a lot for your answer. Sorry if my question is stupid but how do you declare this namespace ? Is there a name for it ?

Thanks again

Regards

Hi,

In general, someone who create the xml file should write namespace definition such as xmlns:i ="http://www.example.org"before using the namespace.

Regards,

Actually, this namespace is declared at the beginning of the XML file, like this:

xmlns:i="http://www.w3.org/2001/XMLSchema-instance"

But when I use the activity DeserializeXml from UiPath.Web.Activities, I have this kind of error:

Deserialize XML: The ‘Email’ start tag on line 79 position 688 does not match the end tag of ‘ProofOfAddressPrintDto’. Line 83, position 178.

That’s why I think there is an issue related to this atomic node…

You have to use localName attribute here @melanie

Please have a view at this thread

1 Like

@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)

Hi,

Thank you gor sharing your exception message.

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

<?xml version="1.0" ?>
<main xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ProofOfAddressPrintDto>
<Email i:nil ="true" />
</ProofOfAddressPrintDto>
</main>

Can you try the above cases to check if you can get smae result. (There might be environment matter)
or
Can you check around first case in details.

Regards,

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.

Thanks again,

Regards

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