[英]How can I append an XML document to an xml node in c# withour the root node?
I have tried this to get(read) the whole xml. 我已经尝试过这样做以获取(读取)整个xml。 here I'm able to copy the whole xml in xmlDoc, but I don't need the root node...
在这里我可以在xmlDoc中复制整个xml,但是我不需要根节点...
XmlNode node = ...... //node from targetxml
node.AppendChild(targetxml.ImportNode(xmlDoc.DocumentElement));
I have also tried this, but not working properly not giving me all the elements in the root node 我也尝试过此操作,但无法正常工作,无法在根节点中提供所有元素
for (int i = 0; i < nodeList.Count; i++)
{
node.AppendChild(xmlDoc.ImportNode(readxml.DocumentElement.FirstChild, true));
readxml.DocumentElement.RemoveChild(readxml.DocumentElement.FirstChild);
}
How can I trim the root node??? 如何修剪根节点???
it some what like this 像这样
//before appending //在附加之前
<tests program="XXX">//root node
//some data //一些数据
</tests>
//after appending //附加后
<tests program="XXX">//root node
//some data //一些数据
<tests program="XXX">//don't need this(tests) node but require all the child node
//other data (all this data is required) //其他数据(所有这些数据都是必需的)
</tests>
</tests>
how can i remove the inner test node 我如何删除内部测试节点
right now im doing like this 现在我正在这样
XmlNodeList nodeList = readxml.SelectNodes("/tests/*");
for (int i = 0; i < nodeList.Count; i++)
{
node.AppendChild(xmlDoc.ImportNode(readxml.DocumentElement.FirstChild, true));
readxml.DocumentElement.RemoveChild(readxml.DocumentElement.FirstChild);
}
but any alternate way??? 但任何替代方式???
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.