Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not recognising documentType..so not loading

Status
Not open for further replies.

fatboyjim77

Programmer
Dec 7, 2006
3
GB
Hi, I've been going over this for 4 hours now so really need a pointer from someone smarter please.

Loading xml file into ASP and cant get it to recognise any root or childnodes. The document is retrieved, and I can print it out, but it doesnt think there a root

URL i'm picking up is:
Code I'm using is:
-------------------------------------
URLToRSS="
Set xmlHttp = Server.CreateObject("MSXML2.XMLHTTP.3.0")
xmlHttp.Open "Get", URLToRSS, false
xmlHttp.Send()
RSSXML = xmlHttp.ResponseText

Set xmlDoc = Server.CreateObject("MSXML2.DomDocument.3.0")
xmlDoc.async = false
xmlDoc.LoadXml(RSSXML)

Set xmlRoot = xmlDoc.documentElement

If isnull(xmlRoot.hasChildNodes()) Then
Response.Write("nothing found")
End If

IF xmlRoot.hasChildNodes() THEN
FOR EACH top IN xmlRoot.childNodes
IF top.NodeName = "event" THEN
etc......

-------------------------------------

This code works happily for other feeds in exactly the same format but not this.. I put the isnull check code in to show it really isnt finding anything.

Pointers appreciated

Thanks
 
Their serving xml is encoded wrong in three places.
[1] Change the encoding="ISO-8859-1" to encoding="UTF-16" at the prolog.
<?xml version="1.0" encoding="ISO-8859-1"?>
[tt]<?xml version="1.0" encoding="utf-16"?>[/tt]
[2] The line of <venue>...</venue> is corrupted at two places where they transmit Caf[highlight]é</[/highlight]venue>, namely, these.
[2.1] [tt]<venue>Marz Bar Caf[highlight]é</[/highlight]venue>[/tt]
[2.2] [tt]<venue>Henrys Bar &amp; Caf[highlight]é</[/highlight]venue>[/tt]
 
tsuji, thanks a million! I copied the XML in question fixed the items you mentioned and it workded!
I have since asked the company in question to fix these accented "e" characters, they did, but another one has slipped in!

Is there any way to trap this issue in the loading of the XML and replace the "é" characters?

Currenrtly the full code breaks (doesnt even load the topnodes or any other items is these characters are present).

I am trying this code by it isnt working: (I would love you thoughts or if there is a workaround). Also ...if anything is wildly out below or repetitive dont hold back:).thanks again

Code:
Set xmlHttp = Server.CreateObject("MSXML2.XMLHTTP.3.0")
xmlHttp.Open "Get", URLToRSS, false
xmlHttp.Send()
RSSXML = xmlHttp.ResponseText
[COLOR=red]RSSXML= Replace(RSSXML,"é","e")[/color]

Set xmlDoc = Server.CreateObject("MSXML2.DomDocument.3.0")
xmlDoc.async = false
xmlDoc.LoadXml(RSSXML)

Set xmlRoot = xmlDoc.documentElement 

Dim strEventID, strLocation

IF xmlRoot.hasChildNodes() THEN
FOR EACH top IN xmlRoot.childNodes
  IF top.NodeName = "event" THEN	
     FOR EACH item IN top.childNodes
        IF item.NodeName = "eventID" THEN
	   strEventID =  item.Text
        END IF
        IF item.NodeName = "location" THEN
	   strLocation =  item.Text
        END IF				 
     NEXT				
    
     Response.Write (strEventID &"<br>")
     Response.Write (strLocation &"<br>")
   END IF
NEXT
END IF
 
You can sure replace a properly encoded é with e using a simple regexp.
[tt]
set rx=new regexp
with rx
.pattern="\xe9"
.global=true
end with
RSSXML= rx.replace(RSSXML,"e")
[/tt]
But the problem could be é itself already corrupted and mis-encoded, then this would not help cure the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top