loading

J

John Hopper

I must be missing something pretty simple. I set a web reference to a web
service and pass it an xml document. At the provider end I validate the
received document against an xsd. I want to parse it after validation using
an xmlNodeReader and selectSingleNode. This works fine when I save the file
first and then xmlDocument.load(uri), with the uri the location of the saved
xml file. But I don't want to save the file. I see I can pass the
xmlDocument.load method a stream, but how do I get the stream to pass it? Any
help very much appreciated. I've tried a number of ways without success.

John Hopper
 
J

John Hopper

Also, I get "root element is missing" (at the "load" step in the snippet
below) when I try what I think should work, ie:

Dim deSer As New XmlSerializer(oReport.GetType)
Dim ms As New MemoryStream
deSer.Serialize(ms, oReport)
Dim theEncoding As New System.Text.UTF8Encoding
Dim str As String = theEncoding.GetString(ms.GetBuffer)
Dim tr As New XmlTextReader(ms)

'Dim sr As New StringReader(oReport.OuterXml.ToString)

'Dim stream As Stream = deSer.Deserialize(

'Dim myXmlReader As XmlReader
Dim myXmlDataDoc As XmlDataDocument = New XmlDataDocument
'myXmlDataDoc.Load("http://localhost/mc/ws050513/doc.xml")
myXmlDataDoc.Load(tr)
 
C

Chad Z. Hower aka Kudzu

=?Utf-8?B?Sm9obiBIb3BwZXI=?= said:
the location of the saved xml file. But I don't want to save the file. I
see I can pass the xmlDocument.load method a stream, but how do I get
the stream to pass it? Any help very much appreciated. I've tried a
number of ways without success.

You have to create a stream. There are memory streams, and many other types.
See the FCL reference or MSDN.
 
J

John Hopper

In the addendum (my 2nd message) above I show code creating a memory file.

Thank you, but that is just giving me "root element missing" at the
xmlDocument.Load step.

John Hopper
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top