hi,
I have a function which reads the xml from a web url into the
XmlTextReader, and then I work my way through the reader producing
html from the different nodes. All the code works fine when I debug
the project, but when I publish the project and run it on a live
server, I seem to be getting problems.
I get the error:
A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection
failed because connected host has failed to respond
My code is as follows:
Dim strURL As String = "http://www.nme.com/clubnmerss"
Dim sb As New StringBuilder()
Dim reader As New XmlTextReader(strURL)
reader.MoveToContent()
Dim sString2 As String = ""
Dim hasEnteredGig As Integer = 0
While reader.Read()
If reader.Name = "venue" Then
hasEnteredGig = 1
sString = sString.Replace("##G##", sString2)
sString2 = ""
Venue = reader.ReadString()
sString += "<div class='gig-box'><img src='media/liv/
club-nme.gif' /><br /></div>"
sString += "<div class='gig'><div class='basic-
headline'><h1>CLUB NME</h1></div>##G##</div>"
sString2 += "<h2>" & Venue & "</h2>"
End If
If reader.Name = "address" Then
Address = reader.ReadString()
sString2 += "<h2>" & Address & "</h2>"
End If
If reader.Name = "url" Then
Url = reader.ReadString()
sString2 += "<h2>" & Url & "</h2>"
End If
If reader.Name = "gig" Then
Gig = reader.ReadString() & "<br />"
sString2 += "" & Gig & ""
hasEnteredGig = 0
End If
End While
If hasEnteredGig = 0 Then
sString = Left(sString, (sString.Length) - 148)
End If
'sString = sb.ToString()
reader.Close()
Like I say this works fine when debuging the project locally, but
fails online.
Hopefully someone can help :)
Martin Honnen - 20 Sep 2007 13:14 GMT
> I have a function which reads the xml from a web url into the
> XmlTextReader, and then I work my way through the reader producing
[quoted text clipped - 7 lines]
> properly respond after a period of time, or established connection
> failed because connected host has failed to respond
I don't think it is a problem with your code using XmlTextReader, there
seems to be a network connection problem you will need to investigate.

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
TheDude5B - 20 Sep 2007 16:07 GMT
> > I have a function which reads the xml from a web url into the
> > XmlTextReader, and then I work my way through the reader producing
[quoted text clipped - 15 lines]
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/
I does occur at this stage in the code, because if I put a Try..Catch
statement around it, it catches the error. Can there be something
blocking the XmlTextReader from accessing the XML document at the web
URL?
Martin Honnen - 21 Sep 2007 13:25 GMT
> I does occur at this stage in the code, because if I put a Try..Catch
> statement around it, it catches the error. Can there be something
> blocking the XmlTextReader from accessing the XML document at the web
> URL?
XmlReader under the hood uses WebRequest/HttpWebRequest to establish a
HTTP connection and that error message sounds as if such a connection
cannot be established.
I am not sure how to help, can you post the URL you are trying to access?
Maybe using an XmlUrlResolver helps, see
<URL:http://msdn2.microsoft.com/en-us/library/System.Xml.XmlTextReader.XmlResolver.aspx>
but the error message simply sounds as if it is not possible to
establish a connection at all.

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/