07-22-2023, 11:58 PM
My solution:
1. Use `Edit > Past Special > Paste XML As Classes` to get the class in your code
2. Try something like this: create a list of that class (`List<class1`>), then use the `XmlSerializer` to serialize that list to a `xml` file.
3. Now you just replace the body of that file with your data and try to `deserialize` it.
Code:
StreamReader sr = new StreamReader(@"C:\Users\duongngh\Desktop\Newfolder\abc.txt");
XmlSerializer xml = new XmlSerializer(typeof(Class1[]));
var a = xml.Deserialize(sr);
sr.Close();
NOTE: you must pay attention to the root name, don't change it. Mine is "ArrayOfClass1"
1. Use `Edit > Past Special > Paste XML As Classes` to get the class in your code
2. Try something like this: create a list of that class (`List<class1`>), then use the `XmlSerializer` to serialize that list to a `xml` file.
3. Now you just replace the body of that file with your data and try to `deserialize` it.
Code:
StreamReader sr = new StreamReader(@"C:\Users\duongngh\Desktop\Newfolder\abc.txt");
XmlSerializer xml = new XmlSerializer(typeof(Class1[]));
var a = xml.Deserialize(sr);
sr.Close();
NOTE: you must pay attention to the root name, don't change it. Mine is "ArrayOfClass1"