Convert XML string to Datatable/Dataset in Cloud

I have been using what might be called a kludge that makes my life very easy. In the configurators I look up all my BOM related information in one place, put it all into a table that I then convert to XML. I include the schema which keeps the data well typed. I put this XML into a method string variable which is effectively a Global variable visible everywhere in the method rules. Then when I need to apply the result to a particular material sequence I pass in the sequence number to a routine. This routine turns the XML back into a datatable using System.IO.StringReader. Then I grab the record I need. It works very nicely and makes the code very simple.

That all works greats in an on-premise, I tried the same in Cloud and of course it rejects references to StringReader.

Before I rewrite this to something else figured I’d ask if there is another way to convert a String that contains XML into a datatable/dataset? I can format the data differently (comma Delimited for example) to get the same result but be great if I can make a simple change to the code below.

ItemList is a string that contains the XML.

System.IO.StringReader StringStream = new System.IO.StringReader(ItemList);
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(StringStream);
System.Data.DataTable dt = ds.Tables[0];

Digging a bit, it looks like I can do similar using JSON, Serialize into JSON text and then deserialize back into Table. The library that does both are available in the cloud.

Where? StringReader is a standard part of System.IO.
Is System.Runtime referenced?

The Configurator code editor appears to have a hard rule that says you can’t use System.IO. Even if I reference it in a comment the code editor rejects it.

This line of code will get the error even though it is commented out.
//System.IO.StringReader StringStream = new System.IO.StringReader(ItemList);

Json it is then :rofl:

I wonder why the restriction? :dumpster_fire:

I think it is to prevent writing files.

I wonder why that’s a problem in a configurator, but not anywhere else?

I think @MikeGross answered my question in a related post. :slight_smile: