string sFile = "f:\\html\\gw\\aa.xml";
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(sFile);
XmlElement ol = xmldoc.CreateElement("ol");
XmlElement li = xmldoc.CreateElement("li");ol.AppendChild(li);
xmldoc.DocumentElement.AppendChild(ol);
//....do other thingsxmldoc.Save(sFile);

解决方案 »

  1.   

    不行啊,我要生成的XML格式如下:
    <ol>
      <li>The big <b>E</b><i>lephant</i> walks slowly.</li>
    </ol>我还应该怎么做?
      

  2.   

    我的XML文件如下:<?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <ol>
      <li>The big <b>E</b><i>lephant</i> walks slowly.</li>
    </ol>
      

  3.   

    string sFile = "f:\\html\\gw\\aa.xml";
    XmlDocument xmldoc = new XmlDocument();
    xmldoc.Load(sFile);
    XmlElement li = xmldoc.CreateElement("li");

    li.InnerXml = "The big <b>E</b><i>lephant</i> walks slowly."; xmldoc.DocumentElement.AppendChild(li);
    xmldoc.Save(sFile);
      

  4.   

    try this:
    objRootlist.LastChild.AppendChild(elem);
    objXml.Save(sFile);