system.io.stream

  • Thread starter Thread starter M. Posseth
  • Start date Start date
M

M. Posseth

Hello i have a problem


i have this peace of code

Dim xmldoc As XmlDocument = fobjXMLSendXMLRequest(strXml)

Dim nodeData As XmlNode = xmldoc.SelectSingleNode("tirep").Item("data")

Dim strdata As String = "<data>" & nodeData.InnerXml & "</data>"

Dim sw As New System.IO.StreamWriter("dmp")

sw.Write(strdata)

sw.Close()

Dim sr As New System.IO.StreamReader("dmp")

Dim dsBrands As New DataSet("brands")

dsBrands.ReadXml(sr)

sr.Close()

DataGrid1.DataSource = dsBrands



This works exactly as wanted however this peace

is in my opinion completely a waste of resources / time

Dim sw As New System.IO.StreamWriter("dmp")

sw.Write(strdata)

sw.Close()

Dim sr As New System.IO.StreamReader("dmp")



as you see the strdata contains xml data that i want to have in a data grid
, i tried to get it to work with a memory stream however then i get an error
, if i write the content of the memory stream to a debug window it is still
valid xml data

how should i go here what is the best solution to skip the IO part ??

as i receive the xml from a webservice as a string , i load it to a XML
document to select the required part



hope someone has a good idea to solve this
 
M. Posseth said:
Hello i have a problem


i have this peace of code

Dim xmldoc As XmlDocument = fobjXMLSendXMLRequest(strXml)

Dim nodeData As XmlNode = xmldoc.SelectSingleNode("tirep").Item("data")

Dim strdata As String = "<data>" & nodeData.InnerXml & "</data>"

Dim sw As New System.IO.StreamWriter("dmp")

sw.Write(strdata)

sw.Close()

Dim sr As New System.IO.StreamReader("dmp")

Dim dsBrands As New DataSet("brands")

dsBrands.ReadXml(sr)

sr.Close()

DataGrid1.DataSource = dsBrands



This works exactly as wanted however this peace

is in my opinion completely a waste of resources / time

Dim sw As New System.IO.StreamWriter("dmp")

sw.Write(strdata)

sw.Close()

Dim sr As New System.IO.StreamReader("dmp")



as you see the strdata contains xml data that i want to have in a data grid
, i tried to get it to work with a memory stream however then i get an error
, if i write the content of the memory stream to a debug window it is still
valid xml data

how should i go here what is the best solution to skip the IO part ??

as i receive the xml from a webservice as a string , i load it to a XML
document to select the required part



hope someone has a good idea to solve this


This is not particularly my area of expertise, but it looks like you
can create a XmlNodeReader from an XmlNode, then DataSet.ReadXml has an
overload that accepts a XmlReader, of which XmlNodeReader is a
subclass.

Haven't had time to try this out myself, though
 

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

Back
Top