XmlDocument and internet connectivity

selvamarcadu

Member
Joined
Jul 7, 2009
Messages
17
Programming Experience
Beginner
Hi,

I am trying to load a xml file and modify a node value.

Dim configXml As XmlDocument = New XmlDocument
configXml.Load(xmlpath)

It works fine when i have the internet connectivity.But as i disconnected internet,I get the following exception pointing the line configXml.Load(...)

"The remote name could not be resolved: 'java.sun.com'"

Am i doing anything silly here?,I welcome your suggestions.


Thanks
selvam
 
Last edited:
Use Try-Catch to catch the exception, so your application doesn't crashes. It is expected that this throws exception when document is not available.
Try...Catch...Finally Statement (Visual Basic)

You can also check for network connection with My.Computer.Network.IsAvailable Property before attempting to load the url, but it is not guaranteed that the connection has internet, or that the document is available still, so a Try-Catch is also appropriate here.
How to: Check Connection Status in Visual Basic

Another approach would be to attempt to download the file first, then load document from file if download was ok, but there's only subtle differences with this.
 
Back
Top