Hi,
I'm serializing a xml string with the following code
StringReader newStringReader = new StringReader(value.Value);
try
{
using (var reader = XmlReader.Create(newStringReader))
{
newStringReader = null;
writer.WriteNode(reader, false);
}
}
finally
{
if (newStringReader != null)
newStringReader.Dispose();
}
but in the written xml file I have
<property i:type="string">
<name>Test</name>
<value>
</value>
</property>
but correct would be
<property i:type="string">
<name>Test</name>
<value></value>
</property>
since the "value" property is an empty string. The way it is serialized not it returns "\r\n ".
Writer:
XmlTextWriter writer = new XmlTextWriter(output);
try { writer.Formatting = System.Xml.Formatting.Indented;
writer.Indentation = 2; // Konfiguration sichern
WriteConfiguration(config, writer);
}
finally { writer.Close(); }
What have I done wrong?
UPDATE: I write a xml configuration file. The values can either be ints, bools, etc or other xml strings. These xml strings are written with the code above. It works fine except for emtpy string elements in the xml string.
UPDATE 2: It works if I manually change the xml string I want to write. I replace all
<tag></tag>
by
<tag/>
Unfortunatley it's not really a "proper" solution to modify a string with regexes.