1
Reply

change a xmlTree

Marco

Marco

Jan 20 2008 5:37 PM
2.7k
Hello, I created my own xmlTree with this last instruction:
   Xml_doc.AppendChild(xml_root);
it is in this way: <html> <script> </script> <body> </body> </html>
Now I need to modify it: for example I need to add <head> </head> in this way:
<html> <head>  <script> </script> </head> <body> </body> </html>
How can I do this? Do I have to re-build the tree???
thanks.
I tried in this way, but It insert only <head/> after <html>. Why? isn't it strange?
EDIT: ------------------------------------------
            XmlElement head = Xml_doc.CreateElement("head");          
            XmlNode body = xml_root.FirstChild;
            xml_root.RemoveAll();
            xml_root.AppendChild(head);
            xml_root.AppendChild(body);
            Xml_doc.AppendChild(xml_root);

Answers (1)