can anyone help me with this simple XML example?

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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top