This is my code to create xmlfile
when i'm writing into it for first time it's working fine.when i'm inserting the content again it showing error only one root node is allowed.
The problem is when i'm additing nodes again i need to append it as a child node to the root node but i don't know how to do it.
Please help me to do this
Sub CreateXmlFile()
Dim objReportNodes As New System.Text.StringBuilder()
Dim strDetails As String
strDate = Request.Form("tBDate").ToString
strTime = Request.Form("lBTime")
strSubject = Request.Form("txtsubject")
strAjanta = Request.Form("txtAjanta")
strDetails = "<?xml version='1.0' encoding='windows-1252' ?>"
strDetails &= "<Messages><Date>" & strDate & "</Date>" & _
"<Time>" & strTime & "</Time>" & _
"<Subject>" & strSubject & "</Subject>" & _
"<Ajanta>" & strAjanta & "</Ajanta>" & _
"</Messages>"
objReportNodes.Append(strDetails)
Dim objFile As System.IO.TextWriter = System.IO.File.AppendText("D:\XMLFile3.xml")
objFile.WriteLine(objReportNodes)
objFile.Close()
objFile = Nothing
objReportNodes = Nothing
Call ReadXmlFile()
End Sub
i tried using AppendChildNode() but here i'm using textwriter so it is not converting to system.xml.xmlnode