NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

XML file to object deserialization

Solved!
Go to solution

How can I implement similar deserialize functionality from XML to object as seen below on a .NET code snippet?

What I understand is that it is using the .NET System.XML.Serialization(4.0.0.0) GAC. If I select this GAC on a step using .NET adapter in TestStand2016 I can't see any classes. Is this correct way to do this?

Computer has .NET framework 4.6.1 SDK installed.

private Macro.Macro[] ReadMacroFile(string macroFileName)

{

FileStream fs = null;

try

{

var ser = new XmlSerializer(typeof(Macro.Macro[]));

fs = new FileStream((new FileInfo(macroFileName)).FullName, FileMode.Open);

var macroList = (Macro.Macro[])ser.Deserialize(fs);

return macroList;

}

finally

{

if (fs != null) fs.Close();

}

}

 

Best Regards

Petri

0 Kudos
Message 1 of 2
(2,778 Views)
Solution
Accepted by topic author Petri

I'm not an expert on this but my guess is that you should just use System.Xml (4.x.x).  Then you can select Serialization.XmlSerializer as your Root Class.  In the .NET invocation you can choose XMLSerializer(type).Deserialize().

 

That should get you going.

 

Let me know if it helps,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 2
(2,771 Views)