日期:2014-05-18  浏览次数:20488 次

asp.net中关于xml数据插入的问题.请帮忙解决一下
请问一下.使用下面代码将oldfile.xml里面的数据读出来之后.怎么样将这条记录加入到另外newfile.xml里面呢.
  XmlDocument   xmldoc   =   new   XmlDocument();
                xmldoc.Load(Server.MapPath( "xzbestnews.xml "));
                XmlNode   Node   =   xmldoc.DocumentElement.SelectSingleNode( "List[@id= ' "   +   ListBox1.SelectedValue   +   " '] ");

查询出来oldfile.xml里面的记录为:

<list   id= "2007060801050550 "   title= "6月生肖运势抢鲜播报 "   url= "/NewsHtml/2007/06/08/20070608010505501.htm "   code= "constellation "   name= "星座 "   time= "2007-6-8   10:50:55 "   vouch= "false "   img= " "   />

怎么样将它插入到newfile.xml当中呢

------解决方案--------------------
请查阅SDK文档中关于XmlNode的方法,我记得有appendChild类似的方法,你只要将新的xml文件读入,然后将原来的XML文档读出的节点作为一个XmlNode插入新文件,再保存就可以了.