I am serializing an object like this:
XmlSerializer serializer = new XmlSerializer(obj.GetType());
using (StringWriter writer = new StringWriter())
{
serializer.Serialize(writer, obj);
return writer.ToString();
}
(having created the nodes like this)
XmlElement newchild = doc.CreateElement(nodename);
newchild.InnerText = data;
targetnode.AppendChild(newchild);
if data!=""
all is well and serializer returns:
<mynode>TheData</mynode>
If data==""
the serializer returns:
<mynode>
</mynode>
Where did that blank line come from?
I've tried the obvious like only setting newchild.InnerText=data
when data is nonblank.