
{
string File = @"c:\TableColumns.xml"
System.Xml.XmlDocument xmlDoc=new System.Xml.XmlDocument()
xmlDoc.Load(File)
System.Xml.XmlNode xn = xmlDoc.DocumentElement.SelectSingleNode("TableColumns/TableColumn[@id=\"IndexUnit\"]")//读取id=IndexUnit的TableColumn节点,在xml教材中的xPath章节专门介绍这种查询方法。
System.Xml.XmlElement vs=xmlDoc.CreateElement("Visibility")//创建新节点
System.Xml.XmlElement Hd = xmlDoc.CreateElement("Hidden")
Hd.InnerText = "true"
vs.AppendChild(Hd)//添加为子节点
xn.AppendChild(vs)
xmlDoc.Save(File)
}
一样的思路,你代码里的 element.AppendChild() 表示在element下添加子元素,想在Schedule下加子节点,就在对应的对象上AppendChild好了。具体到你的代码,应该是 element8.AppendChild(这里面是Create出来的Item节点)
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)