I have a object {System.Collections.Generic.List<object>}
that contains 1000 object {DynamicData}
inside of it, each one with 4 keys and values and one more List
with 2 keys and values inside.
I need to serialize this object into a XML File, i tried normal serialization but it gives me this exception = The type DynamicData was not expected
, how can i serialize this object?
Here is the code:
//output is the name of my object
XmlSerializer xsSubmit = new XmlSerializer(output.GetType());
var xml = "";
using (var sww = new StringWriter())
{
using (XmlWriter writers = XmlWriter.Create(sww))
{
try
{
xsSubmit.Serialize(writers, output);
}
catch (Exception ex)
{
throw;
}
xml = sww.ToString(); // Your XML
}
}
I can create the xml file writing line by line and element by element, but i want something more faster and with less code. The structure of my object is like this:
output (count 1000)
[0]
Costumer - "Costumername"
DT - "Date"
Key - "Key"
Payment - "x"
[0]
Adress - "x"
Number - "1"
[1]...
[2]...