Try it as follow,XmlDocument NxmlDoc = new XmlDocument();
NxmlDoc.LoadXml("<Data text='库存明细'><headdata></headdata></Data>"); XmlNode root = NxmlDoc.DocumentElement;//Create a new node.
XmlElement elem = doc.CreateElement("ccuscode");
elem.InnerText= this.custCode.Value.ToString();
//Add the node to the document.
root.AppendChild(elem);
NxmlDoc.LoadXml("<Data text='库存明细'><headdata></headdata></Data>"); XmlNode root = NxmlDoc.DocumentElement;//Create a new node.
XmlElement elem = doc.CreateElement("ccuscode");
elem.InnerText= this.custCode.Value.ToString();
//Add the node to the document.
root.AppendChild(elem);
xmlDoc.LoadXml("<Data text='库存明细'><headdata></headdata></Data>");
XmlElement xleRoot = doc.DocumentElement;
System.Xml.XmlNode headnode;
headnode = xleRoot.SelectSingleNode("/Data/headdata");
XmlDocument NxmlDoc = new XmlDocument();
xmlDoc.LoadXml("<Data text='库存明细'><headdata></headdata></Data>");
XmlElement xleRoot = xmlDoc.DocumentElement;
System.Xml.XmlNode headnode;
headnode = xleRoot.SelectSingleNode("/Data/headdata");
xmlDoc.LoadXml("<Data text='库存明细'><headdata></headdata></Data>");
XmlNode node=NxmlDox.SelectSingleNode("/Data/headdata");
.....
Node.AppendChild(..)
我希望从第二个对象中取出一个节点,把他下面所有得节点加到另一个对象得某一个节点下面
XmlDocument NxmlDoc = new XmlDocument();
NxmlDoc.LoadXml("<Data text='库存明细'><headdata></headdata></Data>");XmlDocument listdatadoc = new XmlDocument();
listdatadoc.LoadXml(this.custwhlistcontrol.ds.GetXml());
//创建表体记录节点
XmlNode listdata = listdatadoc.SelectSingleNode("/data/tp3_kcgl_custwhrecords");我现在要将listdata下得数据加载到NxmlDoc中(在Data下创建listdata节点),
XmlNode DataNode = NxmlDoc.SelectSingleNode("/Data");
DataNode.AppendChild(listdata); 此句出错错误:"要插入的节点出自不同的文档上下文。"
headnode = new XmlNode();
headnode = this.NxmlDoc.SelectSingleNode("/Data/headdata");
我也是新手,只不过觉得headnode没有被创建就直接赋值有点问题
不能直接加,我是先获得一个字符串,然后加入的
思归说有一个方法 好像是importnode