i have to convert an xml into string
The xml is created as:
System.Xml.Linq.XDocument doc = new System.Xml.Linq.XDocument(new System.Xml.Linq.XDeclaration("1.0", "ISO-8859-1",""));
System.Xml.Linq.XElement root = new System.Xml.Linq.XElement("qcs");
System.Xml.Linq.XElement goal_Name = new System.Xml.Linq.XElement("goal", new System.Xml.Linq.XAttribute("name","abc"));
root.Add(goal_Name);
doc.Add(root);
Console.WriteLine(doc.ToString());
I am getting string as:
<qcs>
<goal name="Goal15">
</goal>
</qcs>
But skipping declaration part which is:
<?xml version="1.0" encoding="ISO-8859-1"?>
I need string as
<?xml version="1.0" encoding="ISO-8859-1"?>
<qcs>
<goal name="Goal15">
<value action="A">0.85</value>
<value action="B">0.87</value>
</goal>
I need to have this too in string. How to do that?