I started this based on a previous discussion on this site: Find Sibling Attribute in XML document
I am working with Wonderware as well and have a string reader I am using to retrieve the tags I need. My string looks like this:
<ItemsList>
<Item Name="soapsystemstaus" Alias="112MIX622_TIME.Barbe_Soap"/>
<Item Name="strSystemDateTime" Alias="112MIX622_TIME.NowMinute"/>
</ItemsList>
This is the code I am trying to run:
dim ItemDBXMLString as string;
dim doc as System.Xml.XmlDocument;
dim SR as System.IO.StringReader;
dim XdbInd as indirect;
XdbInd.BindTo( Me.DIO.Name + "." + Me.DIO.ScanGroup + ".AliasDatabase" );
ItemDBXMLString = XdbInd;
doc = new System.Xml.XmlDocument;
SR = new System.IO.StringReader(ItemDBXMLString);
try
doc.Load(SR);
LogMessage(System.String.Format("SR Loaded into doc! <<<=== ******"));
Note: Indirect is a type of variable that can be used as a pointer to reference other area contents so basically:
XdbInd.BindTo( Me.DIO.Name + "." + Me.DIO.ScanGroup + ".AliasDatabase" );
ItemDBXMLString = XdbInd;
creates a reference to a memory area that contains the string I displayed at the beginning of this post. How to load this string into the Xml Document is the reason for my question. When I get to the instruction: "doc.Load(SR);" i receive an error:
System.Xml: The URL cannot be empty. Parameter name: url
In my ignorance, I never knew I HAD to specify an url in order to read Xml, always thought Xml was a data transport tool. Has anyone else had a similar error when trying to load Xml inside a XmlDocument? Any help or hint is greatly appreciated. (The reason for the full declaration of System.IO.StringReader etc. is due to the lack of Imports in the Wonderware scripting language. Besides the language, it supports .Net framework 4.5)