From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

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,775 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,768 Views)