Using LoadXml Method in UiPath invoke code

Hi guys,

I’m struggling in this prolem, when I try to creat a xml document from a string using method LoadXml, it doesn’t work in UiPath.
This is my simple code:


Can any one help me?

1 Like

image
This is the log, and till now I can not figure it out :((((

@noob_dev

Hello Noob,
try this code to load the XML document from the specified string.

inout_XML = new System.Xml.XmlDocument();
inout_XML.LoadXml("<item><name>wrench</name></item>");

Best regards
Stefan

1 Like

haha I love the way you call me haha. Can I ask u one more thing? Why must I declare inout_XML outside the sequence and also in the invoke code?

1 Like

It is not necessary to initialize inout_XML inside the code, you can do that also in the variable declaration which you assign to the parameter.

But it is always necessary to use the new operator to initialize the variable with a type you need.

1 Like

oh thank you mate :star_struck:

1 Like

hello @StefanSchnell, can I ask u the last thing?
when I try to declare inout_XMLNode = new Systm.Xml.XmlNode();
it doesn’t have that XmlNode() type, is it not allowed to do it?
I’m trying declare some other type and it works good
Thank you

2 Likes

There is a typo, System with e

inout_XMLNode = new System.Xml.XmlNode();
1 Like

image
although I have install the package have system.xml.xmlNode but it still doesn’t work (with no typo) :sweat_smile:

1 Like

It said New cannot be used on a class that is declare ‘MustInHerit’

1 Like

MustInHerit means that a class can be used only as a base class and that you cannot create an object directly from it. You can find an example how to use that here.

2 Likes

Thank you mate

1 Like

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