Skip to content
Discussion options

You must be logged in to vote

Sorry, I meant how are you saving the updated document. I think you would need to use something like this.

using System.Text;
using System.Xml;
using System.Xml.Linq;

// xDoc is the modified XDocument
byte[] bytes;
using (var ms = new MemoryStream())
{
    var settings = new XmlWriterSettings
    {
        Encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false), // no BOM
        OmitXmlDeclaration = true, // optional but usually helps with XMP consumers
        Indent = false,
        NewLineHandling = NewLineHandling.None
    };

    using (var xw = XmlWriter.Create(ms, settings))
    {
        xDoc.Save(xw);
    }

    bytes = ms.ToArray();
}

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@markolbert
Comment options

@markolbert
Comment options

@JimBobSquarePants
Comment options

Answer selected by markolbert
@markolbert
Comment options

@JimBobSquarePants
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants