Click to See Complete Forum and Search --> : Problem with XML/XSL & ASP function


MASTERofPUPPETS
10-05-2005, 06:24 PM
the function
<%
Dim objXML, objXSL

Function ShowXML(strXML,strStyleSheet)
Set objXML = CreateObject("MSXML.DOMDocument")
Set objXSL = CreateObject("MSXML.DOMDocument")
objXML.load(Server.MapPath(strXML))
objXSL.load(Server.MapPath(strStyleSheet))
Response.Write objXML.transformNode(objXSL)
Set objXML = Nothing
Set objXSL = Nothing
End Function
%>


calling the function in an asp file
<%Call ShowXML("http://msn.foxsports.com/feedout/syndicatedContent?categoryId=142","nhl/xsl/news/teamNews.xsl")%>



the errors
1. the http:// part
2. and the ? mark

the error message says that the path has been typed wrong.


any suggestion on how to make this work, would be much appreciated.

thanks.

russell_g_1
10-06-2005, 01:45 PM
the problem is that you are trying to use server.mappath with a url for a different server. you need to retrieve the xml separately and then stick it in the xml document using the loadxml method.

something like this...


<%
response.write gettransformedxml(getXMLFromURL("http://msn.foxsports.com/feedout/syndicatedContent?categoryId=142"),"")
%>


<%

Function getTransformedXML(strXML,strStyleSheet)

dim objXML,objXSL

Set objXML = CreateObject("MSXML2.DOMDocument.4.0")
Set objXSL = CreateObject("MSXML2.DOMDocument.4.0")

objXML.loadxml(strXML)
objXSL.load(Server.MapPath(strStyleSheet))

if objXML.parseerror = 0 and objXSL.parseerror = 0 then

getTransformedXML = objXML.transformNode(objXSL)

end if

Set objXML = Nothing
Set objXSL = Nothing

End Function

function getXMLFromURL(url)

on error resume next

dim httpReq

getXMLFromURL = ""

set HttpReq = createobject("MSXML2.serverXMLHTTP")
HttpReq.open "GET", url, False
HttpReq.send

select case httpreq.status
case 200

getXMLFromURL = HttpReq.responseText

end select

end function

%>

MASTERofPUPPETS
10-06-2005, 02:45 PM
wow, that's awsome.

it works perfectly.


thanks, a lot russell_g_1.