[C#]Add XSL reference in XMLDocument

SofFense

New Member
I am creating an XML document from my C# code. I need to add the XSL reference in my XML document. My code is:\[code\]XmlDocument xDoc = new XmlDocument();if (!File.Exists(fileName)){ XmlDeclaration dec = xDoc.CreateXmlDeclaration("1.0", "UTF-8", null); xDoc.AppendChild(dec); **[Need to add code to add the XSL reference e.g. - <?xml-stylesheet type="text/xsl" href="http://stackoverflow.com/questions/1845699/style.xsl"?> ] ** XmlElement root = xDoc.CreateElement("Errors"); xDoc.AppendChild(root);}else{ xDoc.Load(fileName);}XmlElement errorLogStart = xDoc.CreateElement("ErrorLog");XmlElement errorText = xDoc.CreateElement("Message");errorText.InnerText = message;errorLogStart.AppendChild(errorText);xDoc.DocumentElement.InsertBefore(errorLogStart, xDoc.DocumentElement.FirstChild);FileStream fileXml = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);xDoc.Save(fileXml);\[/code\]I need to add the following line - \[code\]<?xml-stylesheet type="text/xsl" href="http://stackoverflow.com/questions/1845699/cdcatalog.xsl"?>\[/code\] in my XML document. How can I do it? Couldn't find much through google.
 
Top