"<?xml version="1.0"?>" c# linq or XDocument remove encoding=UTF-8 -
xdocument xdoc = new xdocument( new xdeclaration("1.0", null, null), new xelement(bla)); using (var writer = new xmltextwriter(@"folderpath\index.xml", new utf8encoding(false))) { //writer.formatting = formatting.indented; xdoc.save(writer); } i have generate xml document matches sample. code produces:
<?xml version="1.0" encoding="utf-8"?> but should this:
<?xml version="1.0"?> how can solve either xmltextwriter or linq?
see documentation.
if encoding null writes file out utf-8, , omits encoding attribute processinginstruction.
use:
using (var writer = new xmltextwriter(@"folderpath\index.xml", null)) also, see source code xmltextwriter.
Comments
Post a Comment