在XML父节点的开头添加一个节点

The*_*der 2 .net c# xml xmlnode

我想在父级中添加一个 xmlNode,但在顶部/开头。有XMLNode.AppendChild()我可以使用的变体吗?

cro*_*oxy 6

据我了解您的问题,您可能正在寻找该XmlNode.PrependChild()方法。
例子:

XmlDocument doc = new XmlDocument();
XmlNode root = doc.DocumentElement;

//Create a new node.
XmlElement node = doc.CreateElement("price");

//Add the node to the document.
root.PrependChild(node);
Run Code Online (Sandbox Code Playgroud)

MSDN 文档