How can I save an XML structure without declaration?

  • Thread starter Thread starter Markus Freitag
  • Start date Start date
M

Markus Freitag

Guest
Hello,
I'm using namespace empty, nevertheless the header is written.
Can I get a string via the xmlWriter without re-reading it?
Thanks for tips in advance.

protected void SaveRequestXML<T>(string filePath, T dataObject)
{
XmlSerializer serializer = new XmlSerializer(typeof(T));

using (Stream stream = new FileStream(filePath, FileMode.Create))
{
using (XmlWriter xmlWriter = XmlWriter.Create(stream))
{
serializer.Serialize(xmlWriter, dataObject);
}
}
StreamReader reader = new StreamReader(filePath);
string contents = reader.ReadToEnd();
Log.Info("Request Message\n \n" + contents);
}

[XmlType(AnonymousType = true)]
[XmlRoot(Namespace = "", IsNullable = false)]
public class Request
{
/// <remarks/>
public uint OrderNum { set; get; }
}
With best regards Markus

Continue reading...
 
Back
Top