xElement.add new element in uipath(using Linq) gives error

I am trying to build an xml where I have
xmlTree1 = New XElement(“Root”,
New XElement(“Child1”, 1),
New XElement(“Child2”,2)

This works fine and XML is created. I then add
xmlTree1 = xmltree1.Add(new XElement(“NewChild”,555))

Any help is appreciated

xmlTree1 = New XElement("Root",
    New XElement("Child1", 1),
    New XElement("Child2", 2)

xmlTree1.Add(New XElement("NewChild", 555))

yOU USE xmltree T ismall

Are you trying to do this on the right side of an Assign? You can’t do that because xmltree1.Add doesn’t produce a value - it’s just a method that performs an action but doesn’t return a value. For this, you should use Invoke Code instead of Assign.

yeah, I changed it still the same error.

oh yes, I used it in assign.

can you show mw how you are doing?

This is what I did.

Try this one:

Add Functions return nothing its just adding.
If your problem resolved, please mark it as a solution so that others can get help from it.

thanks for your help

1 Like

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