"<?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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -