Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing version from xml file

I am creating a Xml like format using XmlWriter. But in the output there is version information also.

<?xml version="1.0" encoding="utf-8"?>

I don't need this in my file. How can I do that? Is there any way to remove it by code?

like image 759
viky Avatar asked Dec 30 '09 13:12

viky


People also ask

How to delete an element from XML file?

In the XML Files explorer, right-click the XML file or XML element that you want to remove and click Delete.

Do I need the XML file?

Using XML files is advantageous for many reasons including: Readability: For a data analyst, the data must be easily accessible and readable. XML files are easy to comprehend because they use human language with actual words instead of a computer language. For example, XML tag names clearly define and explain the data.

Can I delete XML files on Android?

yes you can delete xml files, but you have to be careful and this is not recommended. But, You cannot get rid of manifest xml file. You can get more help in this previous question.. stackoverflow.com/questions/8037203/…


1 Answers

Use the ConformanceLevel and OmitXmlDeclaration properties. Example:

XmlWriter w;
w.Settings = new XmlWriterSettings();
w.Settings.ConformanceLevel = ConformanceLevel.Fragment;
w.Settings.OmitXmlDeclaration = true;
like image 169
Aviad P. Avatar answered Oct 23 '22 08:10

Aviad P.