Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a node in the beginning of XML parent node

Tags:

c#

.net

xml

xmlnode

I wanted to add a xmlNode in a parent but at the top/beginning. Is there a variant of XMLNode.AppendChild() that i can use?

like image 705
TheCoder Avatar asked Dec 02 '25 22:12

TheCoder


1 Answers

As far as I understand your question you are probably looking for the XmlNode.PrependChild() method.
Example:

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

like image 106
croxy Avatar answered Dec 05 '25 12:12

croxy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!