I've got three problems with some data that I'm serializing.
First off, it outputs <?xml version="1.0" encoding="utf-8"?>
but the program that I'm loading it into only wants <?xml version="1.0"?>
Secondly, whenever the data is empty it will use shorthand for closing the tag (<z303-profile />
) but the program that I'm loading it into won't accept that and requires <z303-profile></z303-profile>
Lastly, I have some data that I can't guarantee how long it will be so I have it in a List. I need each of the items to have their own heading of z305, but it outputs the name of the list that they're being held in first which messes everything up. It's being displayed as follows
<z305List>
<z305>
....
</z305>
<z305>
....
</z305>
</z305List>
with the list being stored as
[XmlArrayItem("z305")]
public List<LocalPatronInfo> z305List = new List<LocalPatronInfo>();
The code I'm using for serialization is as follows
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");
XmlSerializer xmls = new XmlSerializer(typeof(AllRecords));
TextWriter tw = new StreamWriter(richTextBoxWorkingDir.Text + "\\" + filename);
xmls.Serialize(tw, allRecords, ns);
tw.Close();