M
Milsnips
hi there,
i am currently using the following code to generate an XML object, then save
it, then read the contents of the file - but i dont wanna save it, instead
read it directly after i;ve created the object.. see below:
------------------------------
Dim w As New XmlTextWriter(Server.MapPath(".") & "\suppliers.xml",
System.Text.Encoding.UTF8)
w.Formatting = Formatting.Indented
w.WriteStartDocument()
w.WriteStartElement("suppliers")
Dim ds As DataSet = MyFunction.GetSuppliers()
If ds.Tables(0).Rows.Count > 0 Then
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
w.WriteStartElement("ROW")
Dim dr As DataRow = ds.Tables(0).Rows(i)
w.WriteElementString("text", dr("supplier"))
w.WriteElementString("value", dr("supplierID"))
w.WriteEndElement()
Next
End If
w.WriteEndElement()
w.WriteEndDocument()
w.Flush()
w.Close()
w = Nothing
Dim xd As New XmlDocument
xd.Load(Server.MapPath(".") & "\suppliers.xml")
Response.Write(xd.OuterXml)
xd = Nothing
GC.Collect()
i am currently using the following code to generate an XML object, then save
it, then read the contents of the file - but i dont wanna save it, instead
read it directly after i;ve created the object.. see below:
------------------------------
Dim w As New XmlTextWriter(Server.MapPath(".") & "\suppliers.xml",
System.Text.Encoding.UTF8)
w.Formatting = Formatting.Indented
w.WriteStartDocument()
w.WriteStartElement("suppliers")
Dim ds As DataSet = MyFunction.GetSuppliers()
If ds.Tables(0).Rows.Count > 0 Then
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
w.WriteStartElement("ROW")
Dim dr As DataRow = ds.Tables(0).Rows(i)
w.WriteElementString("text", dr("supplier"))
w.WriteElementString("value", dr("supplierID"))
w.WriteEndElement()
Next
End If
w.WriteEndElement()
w.WriteEndDocument()
w.Flush()
w.Close()
w = Nothing
Dim xd As New XmlDocument
xd.Load(Server.MapPath(".") & "\suppliers.xml")
Response.Write(xd.OuterXml)
xd = Nothing
GC.Collect()