Vijay Jadhav
Vijay Jadhav

Reputation: 123

Reading a XML document in VB.net from the internet

Take a example..

Private Sub Button2_Click_1(sender As Object, e As EventArgs) Handles Button2.Click

        WebBrowser1.Navigate("http://example.com/page.xml")

    End Sub

Above code displays the XML content in webbrowser1 control on Button_Click. But I dont want display in webbrowser. I want read the content from xml document to use elsewhere.

I just need to know how to get this XML file to use elsewhere (other than webbrowser control) from a web address...

Thanks in advance...

Upvotes: 0

Views: 1744

Answers (1)

Steven Doggart
Steven Doggart

Reputation: 43743

The XmlDocument.Load method can be given either a local file name or a web address URL, for instance:

Dim doc As New XmlDocument()
doc.Load("http://example.com/page.xml")

The Load method of the XDocument and XElement classes also work the same way.

If you want to get the XML document as a string, so you can parse it through some other means, such as the XmlSerializer, you can use the HttpWebRequest class. See this page for an example:

http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.getresponse.aspx

Upvotes: 3

Related Questions