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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Might be ASP or XML problem...

Status
Not open for further replies.

mtarby

Programmer
Feb 19, 2003
89
US
I've got an XML feed that I'm trying to write out in an asp page (I'll confess this is the first time I've tried this).

The xml looks good, but the code I have on the asp page won't display the feed:

<!--#include file="subWriteRss.asp"-->
<%
Function getXML(sourceFile)
dim styleFile
dim source, style
styleFile = Server.MapPath("rss.xsl")

Dim xmlhttp
Set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")
xmlhttp.Open "GET", sourceFile, false
xmlhttp.Send

set source = Server.CreateObject("Microsoft.XMLDOM")
source.async = false
source.loadxml(xmlhttp.ResponseText)

set style = Server.CreateObject("Microsoft.XMLDOM")
style.async = false
style.load(styleFile)

getXML = source.transformNode(style)
set source = nothing
set style = nothing
End Function
%>
<html>
<body>
<%= getXML(" %>
</body>
</html>

Does anything look inherently strange? Or is it something I'm doing wrong with the XML portion?

Thanks in advance for any advice...
 
does this line of code error?

Code:
<%= getXML("[URL unfurl="true"]http://www.lemoyne.edu/admission/rss/news.xml")[/URL] %>

it looks like it is searching for a function

to display the infomation use

Code:
<%=source.transformNode(style)%>

hth

simon
 
I'm confused by that last reply, so I'll post my own:

What error are you receiving?
Have you tried putting in Response.Write's to see things like what the length of the responseText is (or even if it is passing back a 404 error or something like that).

Try printing th responseText diectly to the page with xsl or anything.

Again, the type of error and error text would be handy. It could be erroring out trying to go get the page, erroring in the transformation, erroring in the trip back from the remote server, etc. to many variables.

Another thing to check would be the xmlHTTP.status. If it is 200 everything is fine as far as talking to the rmeote server and getting something back. 404, 500, etc would not be good things.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Right, andhe has tat function defined atthe top of the page, plus he was using the suggested source.transformNode(style) inside that function and setting the return value of the function equal to that transformation...which is why i was a little confused with your reply :)

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
I'm not getting any error - just a blank page, so I'll try your suggestions and see what I can figure out.

Thanks! But I might be back!

Michelle
 
It won't be, I would suggest not removing that :)

My guess is that somewhere your XML is becoming blank, so the transform runs, finds nothing to do, and returns nothing that you then write to the screen.

Another thing you can check is:
If source.ParseError.ErrorCode <> 0 Then
Response.Write "A Parse Error Occurred Loading the XML: " & source.ParseError.Reason
End If

I would add that in right after you attempt to load the xml from ResponseText. Before you go to load it I would put in something along the lines of:

Response.Write "<div border=""2px solid grey;"">XML Reeived: " & len(xmlhttp.ResponseText) & " characters long.<br>HTTP Status Code: " & xmlhttp.status & "</div>"


If you ant to output the xmnl to make sur your getting it ok (instead of an error message or soemthing): Response.Write "<xmp>" & xmlhttp.response.text & "</xmp>"

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Cool - I'm at least getting somewhere now. I added the parse error check and it returned:

Switch from current encoding to specified encoding not supported

So I'm off to decipher what that means...

 
Nothing like pasting error messages into google, sometimes it works, sometimes it doesn't. Here's one that showed up, if it dosn't help paste the error message in for a bunch of other stuff:
-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top