使用c#System.Xml将<link href =“template.css”rel =“stylesheet”type =“text / css”/>节点添加到xml文件中

时间:2011-03-04 05:24:12

标签: c# asp.net xml

我正在使用System.Xml创建一个xml文件....所以首先我到目前为止...

        XmlDocument xmldoc = new XmlDocument();
        XmlNode docNode = xmldoc.CreateXmlDeclaration("1.0", "UTF-8", null);
        xmldoc.AppendChild(docNode);

        XmlNode Doc = xmldoc.CreateDocumentType("html", "-//W3C//DTD XHTML 1.1//EN", "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd", null);
        xmldoc.AppendChild(Doc);
        //XmlNode htmlNode = htmlNode.;

        XmlNode xmlRoot, xmlNode;

        xmlRoot = xmldoc.CreateElement("head");
        xmldoc.AppendChild(xmlRoot);

        xmlNode = xmldoc.CreateElement("Child");
        xmlRoot.AppendChild(xmlNode);
        xmlNode.InnerText = "This is the first Child";

         xmlNode.InnerText = TextBox1.Text;

        xmlNode = xmldoc.CreateElement("Child2");
        xmlRoot.AppendChild(xmlNode);
        xmlNode.InnerText = "This is the second Child";

        xmlNode = xmldoc.CreateElement("Child3");
        xmlRoot.AppendChild(xmlNode);
        xmlNode.InnerText = "This is the third Child";

        string filename = @"D:\Anusha\xmlFiles" + DateTime.Now.Day + DateTime.Now.Month + DateTime.Now.Minute + ".xml";

         string filename = @"c:\NewXML" + ".xml" or @"c:\whatever" + ".xml"

        xmldoc.Save(filename);

我需要添加.css文件

到我的xml文档...... 我该怎么办?

1 个答案:

答案 0 :(得分:0)

如果我没错,试试这个

 <?xml-stylesheet href="common.css" type="text/css"?>
 <?xml-stylesheet href="modern.css" title="Modern" media="screen" type="text/css"?>
 <?xml-stylesheet href="classic.css" alternate="yes" title="Classic" media="screen, print" type="text/css"?>