Web.Activities 1.4.5 XML element Error: Object reference not set to an instance of an object

Hi All,
This is about UiPath.Web.Activities.

Situation 1: When Root element have the attribute and I want to access the element down below I am getting error: “Object reference not set to an instance of an object.”

In below example: xmlns=“somedata” in instruction element.
XMLFile.Element(“instruction”).Element(“header”).Element(“interchangeid”).Value this is giving error.
image

Situation 2: When I remove the attribute xmlns=“Somedata” from instruction. Then no error.
image

I need help on Situation 1, on how to fix the error.
I am using UiPath.Web.Activities 1.4.5
image

Hy @navin.singh,

Please check the Repair option in the selector, UiPath will try tofigure it out on its own.

Also use the Open Ui Explorer to enhance your selector, you will se everything the UiPath can capture on the component.

Please let me know if it works

Regards

I have done it this way.
image

image

Hy @navin.singh,

If you want to get an attribute for a component use the ‘Get Attribute’ component.

image

Give it a try and let me know

Regards

Hi @William_Blech_Sister, I am trying to read from xml file on local folder.

This is the xml file I am trying to read instruction_edi_problem_mini.xml (325 Bytes)

Hy @navin.singh,

I am getting the same error you are, it appears that the desirialize XML appear working properly.

I will continue trying and get back to you latter.

Regards

1 Like

@navin.singh
it looks like your XML has defiend a namespace (somedata, but ensure the value somedata is accepted as a valid namespace or edit it accordingly) and therefore you cannot work with local name only.

test it with a log message and yourXDocVar.Root.Name.toString

Handling namespace have a look here:

1 Like

@ppr. It took sometime to understand your code as I am new. But It works. Thanks a lot.

1 Like

Thanks for help @William_Blech_Sister :slightly_smiling_face:

@navin.singh,

You are welcome, I did not get the solution but learn nothing new on this :slight_smile:

I used. Thanks to @ppr

XMLfiledata.Element(Xmlns+“instruction”).Element(Xmlns+“header”).Element(Xmlns+“interchnageid”).Value.ToString

Xmlns = “somedata” (Type XNamespace)
XMLfiledata.- is my XDocument variable.

For the XML file in example below.

image

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