I am making an addendum for an XML, I go through the file with a split but I have heard that good practice would be to deserialize. How do I go through the xml and transform it into an object to manipulate it?
I am making an addendum for an XML, I go through the file with a split but I have heard that good practice would be to deserialize. How do I go through the xml and transform it into an object to manipulate it?
Deserialization does not need to go through anything, you just have to be able to map the xml with a class that you define.
Having the xml you can get the class that maps with this using tools such as
or you can use Visual Studio to get the class that you get from the xml
Generate Class From JSON or XML in Visual Studio
The idea is that later you use
XmlSerializer mySerializer = new XmlSerializer(typeof(MySerializableClass));
FileStream myFileStream = new FileStream("myFileName.xml", FileMode.Open);
MySerializableClass myObject = (MySerializableClass)mySerializer.Deserialize(myFileStream);
where it says MySerializableClass
you must indicate the class that you get from the xml structure