首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

dataelement.AppendChild(elem)错误

2012-01-24 
dataelement.AppendChild(elem)异常我将一些信息写入xml文件,做了个按钮,第一次点击按钮能成功写入xml,第

dataelement.AppendChild(elem)异常
我将一些信息写入xml文件,做了个按钮,第一次点击按钮能成功写入xml,第二次点击按钮,程序运行到dataelement.AppendChild(elem)的时候报错:
未处理的“System.ArgumentException”类型的异常出现在 System.Xml.dll 中。

其他信息: 要插入的节点出自不同的文档上下文。
部分代码如下,请高手帮我分析分析! 谢谢!  
 For Each it In DataGridView_dataelement.Rows
  elem = FormBrowser.tpldoc.CreateElement("elem")
  If it.Cells(0).Value <> "" And it.Cells(1).Value <> "" And it.Cells(2).Value <> "" Then
  elem.SetAttribute("from", it.Cells(0).Value)
  elem.SetAttribute("to", it.Cells(1).Value)
  elem.SetAttribute("toelementtype", it.Cells(2).Value)
  dataelement.AppendChild(elem)

[解决办法]
没用过,问题应该出在写入xml文件操作,第二次操作不正常,应该检查为什么不能往已经有一定数据的xml文件里写入。
[解决办法]
帮楼主顶顶。

热点排行