Am trying to create am xml document using string builder as follows. string builder having the exact value as expected. but it does not write to the xml file. following is the code
mssql = "select ID, ParentID, OrderID, Title, Start, End, PercentComplete, Expanded, Summary From Project"
Dim buildXML As New StringBuilder
buildXML.Append("<?xml version=""1.0"" encoding=""utf-8""?><Project> <Tasks>")
Dim mycommand As OdbcCommand
mycommand = New OdbcCommand(mssql, dbcon)
dbcon.Open()
Dim reader As OdbcDataReader
reader = mycommand.ExecuteReader
While reader.Read
buildXML.Append("<Task>" & _
"<ID>1</ID>" & _
"<ParentID />" & _
"<Start>" & reader.Item("Start") & "</Start>" & _
"<End>" & reader.Item("End") & "</End>" & _
"<Title>" & reader.Item("Title") & "</Title>" & _
"<PercentComplete>" & reader.Item("PercentComplete") & "</PercentComplete>" & _
"<Summary>" & reader.Item("Summary") & "</Summary>" & _
"<Expanded>" & reader.Item("Expanded") & "</Expanded>" & _
"<OrderID>" & reader.Item("OrderID") & "</OrderID>" & _
"</Task>")
End While
buildXML.Append("</Tasks> <Dependencies /></Project>")
reader.Close()
dbcon.Close()
'everything work fine up to this
Dim XMLDocument As System.Xml.XmlDocument = New System.Xml.XmlDocument()
XMLDocument.LoadXml(buildXML.ToString())
Dim Output As New XmlTextWriter(Server.MapPath("~/App_Data/gantt.xml"), System.Text.Encoding.UTF8)
XMLDocument.WriteTo(Output)
saving the document will result in empty document, does anyone know the reason?
No comments:
Post a Comment