adding new child nodes to XML on each function call

aRsi

New Member
I have an XML file and I have a function to which this XML is passed as string. I have loaded this string in Xmldocument and I need to insert few children nodes under one node. This function returns the modified XML string. I want that whenever this function is called, new child nodes are added, currently, It adds child nodes once.Do I need to overwrite the XML file ? If so, How can I replace the node with new node ( with new child nodes added) so that It has child nodes added before the function is called again ?My code looks something like this:\[code\]Dim doc As New XmlDocumentdoc.LoadXml(applicationXml)Dim parentNode As XmlNode = doc.GetElementsByTagName("prList").Item(0)Dim newElement As XmlNode = doc.CreateNode(XmlNodeType.Element, "gate.util.persistence.LanguageAnalyserPersistence", Nothing)Dim runtimeParamsElement As XmlNode = doc.CreateNode(XmlNodeType.Element, "runtimeParams", Nothing)Dim xa As XmlAttribute = doc.CreateAttribute("class")xa.Value = "http://stackoverflow.com/questions/10561694/gate.util.persistence.MapPersistence"runtimeParamsElement.Attributes.Append(xa)localMapElement = doc.CreateNode(XmlNodeType.Element, "localMap", Nothing)featuresElement.AppendChild(localMapElement)newElement.AppendChild(featuresElement)Return doc.InnerXml\[/code\]
 
Back
Top