Re: Read Xml data
From: Martyn Fewtrell (mfewtrell_at_networkclub.co.uk)
Date: 07/26/04
- Next message: WilsonSmith: "Setting the backcolor"
- Previous message: Kevin Spencer: "Re: Non secure items on SSL in asp.net"
- In reply to: John Saunders: "Re: Read Xml data"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 26 Jul 2004 18:18:08 +0100
"John Saunders" <johnwsaundersiii@notcoldmail.com> wrote in message
news:uo92kKzcEHA.3480@TK2MSFTNGP11.phx.gbl...
> "Martyn Fewtrell" <mfewtrell@networkclub.co.uk> wrote in message
> news:OScPwtwcEHA.2724@TK2MSFTNGP12.phx.gbl...
> > I am having a problem reading an Xml file and loading it into a dataset
in
> > VB.net (ASP).
> >
> > I seem to be able to load the remote file from the Url but once in
memory
> I
> > cant manage to load it in to a dataset.
> >
> > The readXml appears to want to read a file rather than a variable and
I'm
> > not sure how to get around this issue.
> >
> > I've tried loading to a file stream and converting the strFile to an
> > XmlDocument but this doesn't appear to get me any further.
> >
> > I known the code at the bottom doesn't work I have listed it to put over
> the
> > idea of what I am trying to do.
>
> Martyn,
>
> The first thing you need to do is get something out of the WebResponse. If
> you look at the documentation for WebResponse, you'll see that there is a
> WebResponse.GetResponseStream method which returns a Stream.
>
> Next, if you look at the documentation for DataSet.ReadXml, you'll see
that
> there is an overload which accepts a Stream as input. Putting this
together,
> you get:
>
> 'get data
>
> Dim Url As String = "http://www.url/file.xml"
> Dim Request As WebRequest
> Dim Response As WebResponse
> Dim strFile As String
>
> Dim ds As DataSet = New DataSet
>
> Try
> Request = WebRequest.Create(Url)
> Response = Request.GetResponse()
> litError1.Text = "Response Recieved"
>
> Dim responseStream As Stream = Response.GetResponseStream()
> 'load Dataset
> ds.ReadXml(responseStream)
> Catch ex As Exception
> litError1.Text = "Response Not Recieved"
> End Try
>
> --
> John Saunders
> johnwsaundersiii at hotmail
>
>
Thanks John
I shall try this this evening and see how it all fits together!
Martyn
- Next message: WilsonSmith: "Setting the backcolor"
- Previous message: Kevin Spencer: "Re: Non secure items on SSL in asp.net"
- In reply to: John Saunders: "Re: Read Xml data"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|