Hi i have an xml file that looks like this (very basic)
I would like to add child element/s to my myRoot element using vb .net2.
I am getting "This document already has a 'DocumentElement' node." Error with the following code
Can anyone help with this (im new to this) and have googled for a bit which only seemd to complicate it for me.
Visual Studio 2005 (sp1)
dotnet 2.0
VB.NET:
[LEFT]<?xml version="1.0" encoding="utf-8"?>
<myRoot />[/LEFT]
I would like to add child element/s to my myRoot element using vb .net2.
I am getting "This document already has a 'DocumentElement' node." Error with the following code
VB.NET:
[LEFT] Dim myXmlDoc As XmlDocument = New XmlDocument()
Dim myElement As XmlElement[/LEFT]
[LEFT] myXmlDoc.Load("c:\test.xml")
myElement = myXmlDoc.CreateElement("newChild")
myXmlDoc.AppendChild(myElement)[/LEFT]
[LEFT] myXmlDoc.Save("c:\test.xml")[/LEFT]
Can anyone help with this (im new to this) and have googled for a bit which only seemd to complicate it for me.
Visual Studio 2005 (sp1)
dotnet 2.0