gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 17:29:57 24 4
gpt4 key购买 nike

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

最佳答案

据我了解你的问题,你可能正在寻找 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);

MSDN documentation

关于c# - 在 XML 父节点的开头添加一个节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34918867/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com