Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Cull all the namespaces.
- // You may want to add your own here though, so replace .Add with .Add("prefix", "namespace");
- var namespaces = new XmlSerializerNamespaces();
- namespaces.Add(string.Empty, string.Empty);
- // While we're at it, that XML version declaration can go to hell too.
- var settings = new XmlWriterSettings { OmitXmlDeclaration = true };
- var serializer = new XmlSerializer(dataType);
- using (var memoryStream = new MemoryStream())
- {
- using (var writer = XmlWriter.Create(memoryStream, settings))
- {
- serializer.Serialize(writer, this.Data, namespaces);
- // And do whatever you want with writer at this point.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement