tags:

views:

38

answers:

2

Hi, I wanna insert in second line :

<?mso-application progid="Excel.Sheet"?> 

but I'm started to think that it is impossible.

Here is my base code:

 XmlDocument doc = new XmlDocument();


                XmlReader reader = cmd.ExecuteXmlReader();


                doc.LoadXml("<results></results>");


                XmlNode newNode = doc.ReadNode(reader);

                while (newNode != null)
                {
                    doc.DocumentElement.AppendChild(newNode);
                    newNode = doc.ReadNode(reader);

                }
+2  A: 

<?mso-application progid="Excel.Sheet"?> is a processing instruction not an element so you need to use the CreateProcessingInstruction Method

Mark
+2  A: 

Just Try like this

     XmlNode XNode = doc.CreateProcessingInstruction("mso-application ", "progid=\"Excel.Sheet\"");
     doc.AppendChild(XNode);
Pramodh