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?

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

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?

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.

oh thank you mate :star_struck:

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

There is a typo, System with e

inout_XMLNode = new System.Xml.XmlNode();

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

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

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.

Thank you mate