如何在XML文件的指定节点下写入值?

<SQLDiary>
<Imformation title="更新" time="2013-11-6" info="备注说明" sql="select * FROM B_MS"/>
</SQLDiary>
我想要在<SQLDiary>的节点下循环写入
<Imformation title="更新" time="2013-11-6" info="备注说明" sql="select * FROM B_MS"/>这样类似的子节点,求详细方法

 

 XmlDocument doc = new XmlDocument();

              doc.LoadXml("<SQLDiary>  <Imformation title=\"更新\" time=\"2013-11-6\" info=\"备注说明\" sql=\"select * FROM B_MS\"/></SQLDiary>");
  XmlNode root = doc.DocumentElement;
  //Create a new node.
              XmlElement elem = doc.CreateElement("Imformation");
              elem.InnerText = "title=\"更新\" time=\"2013-11-6\" info=\"备注说明\" sql=\"select * FROM B_MS";
  //Add the node to the document.
              root.AppendChild(elem);
  Console.WriteLine("Display the modified XML...");
              doc.Save(Console.Out);
              Console.Read();

  

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答