Reading an xml feed Question Please help

vbMarkO

Well-known member
Joined
Aug 19, 2005
Messages
157
I wasnt sure where else to put this question....

Here is what I am wanting to do.

I have a Blog feed of which I am wanting to read .....

Here is how this blog works... its an artist blog... Im the artist.... I am wanting to read the xml feed at http://mbstudiosdailypaintings.blogspot.com/atom.xml and within each post on the blog is a image ... I am wanting to get the image and add it to a gallery to be viewed on a web page.

So each new image automatically add it to the gallery.

vbMarkO
 
WebRequest and WebResponse

There are three parts to this - downloading the XML feed, parsing the XML, and downloading the images. I suggest using the WebRequest and WebResponse classes:

C#:
WebRequest      webReq;
WebResponse     webResp;
XmlDocument     xDoc;
Image           dlImage;

webReq = WebRequest.Create("http://mbstudiosdailypaintings.blogspot.com/atom.xml");
webResp = webReq.GetResponse();

xDoc = new XmlDocument();
xDoc.Load(webResp.GetResponseStream());

//Parse XML here


//To get an image:
webReq = WebRequest.Create(urlToTheImage);
webResp = webReq.GetResponse();

dlImage = Image.FromStream(webResp.GetResponseStream());

//Do something with dlImage

All thats needed now is code for parsing the image URLs out of the XML, and making the code more robust.

Good luck :cool:
 
Im sorry I guess I should of stated I dont do C#

I might be able to convert it but then IM not sure here as I get turned around when it comes to C#

VbMarkO
 
Conversion

In this case the conversion from C# to VB.Net is simple, as no control structures have been used.

  1. Change the first 4 lines:

    Code:
    Dim webReq As WebRequest
    Dim webResp As WebResponse
    Dim xDoc As XmlDocument
    Dim dlImage As Image
  2. Change comment lines // to
  3. Remove the trailing semicolons from all other lines

If you edit your profile, you can specify your .Net preferred language, and this is displayed in your user info next to each post.

:)
 
Back
Top