Importing XML data from a web page

I’ve seen samples of reading an xml file from the computer in XMLDocument and also looked at XMLReader, but how do I go about reading xml from a web page? The page will be a variable and I know what the node structure is. Just not sure how to go about sucking the info from the nodes via a url into my app. Here is a sample of the info I need to import: . I’ll be getting the lang_code and lang_translation node info.

I think i figured it out. Now i just have to parse the data. shouldn’t be too hard.

Dim socket1 As New HTTPSocket Dim data As String = socket1.Get(newURL, 300) textArea1.text = data

I have another question. This works, however, I’d like to be able to warn the user if the file cannot be downloaded for some reason (like internet connection is out or the website is down). how do i use httpsocket.errorcode? I tried this but it didn’t seem to work when I turned off my wifi:

data = socket1.Get(newURL, 300) if socket1.ErrorCode = -1 then msgBox "A connection to YouTube was not able to be established. Check your internet connection and try again." return end if

Subclass the socket, use asynchronous requests. I’m honestly surprised YouTube is responding to your HTTP 1.0 requests. ErrorCode may not always be -1 for a failure to connect. This is also something that would be fixed by subclassing a socket.

Using Xojo.Net.HTTPSocket, you can use the Error event to report errors to the user: http://developer.xojo.com/xojo-net-httpsocket

thanks, Tim. might be a bit above my level of programming (cut me a break, i was an art major), but i’ll try to see if i can understand it. btw, i noticed this on that page: “Apple may reject your App Store submission if you app uses these settings without valid reasons.”
I’d like to get my app into the App Store, so i’m wondering if this might be a show stopper for me.

That applies specifically to making requests that aren’t using HTTPS. YouTube/Google is ready to accept requests over HTTPS, so you will be fine, so long as every request is secure. Noone can tell you much more than that without knowing specifics of your app.

If you’re doing anything with YouTube, be aware that Google has an API for that, and you should be using it.

I was a theatre major, so even us artsy folk can make apps! All one has to do is sit down and read the documentation, Xojo makes app development very easy for every level of programmer.

yeah i’m using the api for youtube. pretty cool. glad to see i’m not alone in my more creative background, but i think in many respects it helps me as a programmer too. have to think creatively a lot. i am using https, btw.

[quote=356723:@Patrick Besong]I have another question. This works, however, I’d like to be able to warn the user if the file cannot be downloaded for some reason (like internet connection is out or the website is down). how do i use httpsocket.errorcode? I tried this but it didn’t seem to work when I turned off my wifi:

data = socket1.Get(newURL, 300) if socket1.ErrorCode = -1 then msgBox "A connection to YouTube was not able to be established. Check your internet connection and try again." return end if [/quote]
HTTPSocket.StatusCode will be zero in the event of a timeout. Otherwise it will reflect the status of the request. 400-499 is a client error (404 is page not found), 500-599 is a server error (like a database being down).

A description can be found here https://en.m.wikipedia.org/wiki/List_of_HTTP_status_codes