Click here to Skip to main content
15,909,242 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to load a xml document from a web to my program
so i wrote these lines:

VB
Dim xDoc As XmlDocument = New XmlDocument()            xDoc.Load("http://www.ims.gov.il/ims/PublicXML/isr_cities.xml")


sometimes it works well,but sometimes it fail
when it fail sometimes it throw this exception :
"Too many automatic redirections were attempted."
and sometimes it look like everything okay but it is fail to load the xml document to my object of "XmlDocument"
i discovered it because in the property "innerxml"
instead of containing xml of my document it containing html like:

<pre lang="HTML"><html><body><script>document.cookie='bbbbbbb=53cf4d9cbbbbbbb_53cf4d9c; path=/';window.location.href=window.location.href;</script></body></html>



what can I do in order to fix it ???

please help me -it very urgent!!!!
thank you so much

What I have tried:

VB
xDoc = New XmlDocument()
                xDoc.Load("http://www.ims.gov.il/ims/PublicXML/isr_cities.xml")
                rssNodes = xDoc.SelectNodes("/IsraelCitiesWeatherForecastMorning/Location")


but it fail
Posted
Updated 11-Apr-16 6:25am
v3

The problem is not one of coding, it is an issue with the website. Talk to the web master about it. And sorry, but it is not at all urgent to anyone here.
 
Share this answer
 
Comments
Member 12451084 11-Apr-16 8:11am    
i dont have connection to the web master,maybe you have an indirect solution,
please response to this comment , there are not answers for it in the enternet
thanks a lot.
Richard MacCutchan 11-Apr-16 8:28am    
Solution to what? If the URL does not present an XML document then there is nothing you can do.
Both symptoms are hint to a connection (slow response) problem...
As Richard told you, there is nothing wrong with the code, so you have to solve the occasional failures in an other way...
Wrap your load in a try catch block and repeat it until the XML loaded perfectly (probably a schema check)...
Also a good idea to cache the XML on your own server, and only load it once or twice a day (in any case meteorological data does not change too fast)...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900