TestStand | Exporting a Variable to an XML String

TestStand has a cool feature where you can export a TestStand variable (like locals, Parameters) to an XML String. It also has a corresponding function to import an XML String to a TestStand variable.

Exporting a TestStand Variable to an XML String

The function to get the XML of a variable and to store it in a local variable called "MyStr" is
Locals.MyStr = <VariableName>.GetXML(0,0)

For example, lets say you have a Parameter variable called "MyContainer".


You can get the XML of this variable by using the function:
Locals.MyStr = Parameters.MyContainer.GetXML(0,0)

The Locals.MyStr would contain the below XML Data:

<?TS version="2019 (19.0.0.170)"?>
<Prop Name='MyContainer' Type='Obj' Flags='0x4'>
 <Prop Name='MyNumber' Type='Number' Flags='0x0'>
  <Value>5</Value>
 </Prop>
 <Prop Name='MyString' Type='String' Flags='0x0'>
  <Value>Pi Genie!</Value>
 </Prop>
 <Prop Name='MyBoolean' Type='Boolean' Flags='0x0'>
  <Value>True</Value>
 </Prop>
</Prop>

Importing the XML String back to the TestStand Variable

The function to import the XML string to a variable is
<TestStand Variable Name>.SetXML(<XML String>,0,0)

Example:
Parameters.MyContainer.SetXML(Locals.MyXMLStr,0,0) 

In the above example, "Locals.MyXMLStr" contains the XML String and it is imported to the TestStand variable "Parameters.MyContainer"

No comments:

Feel free to leave a piece of your mind.

Powered by Blogger.