PDA

View Full Version : XML display problem


fogofogo
11-18-2005, 05:14 PM
Hello all,

I'm trying to display some information thats pulled from an XML page, formatted with an XSL sheet and then pulled into a html page using javascript. I'm using javascript instead of php or asp, as I need to use the script on both a windows and an apache server.

It works fine locally, but when I upload it to a server, the page is displayed without the XML info and warning that says "error on page".

Here is my XSL:

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">
<html>
<body>

<table border="1">
<tr bgcolor="#B07946">
<th align="left">Name :</th>
<th align="left">Buyin :</th>
<th align="left">Entry Fee :</th>
<th align="left">Currency : </th>
<th align="left">State :</th>
<th align="left">Players :</th>
<th align="left">Blinds :</th>
<th align="left">Type :</th>
<th align="left">Limit :</th>
<th align="left">Start Time :</th>
</tr>
<xsl:for-each select="xmlfeed/tournament">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="buyin"/></td>
<td><xsl:value-of select="entryfee"/></td>
<td><xsl:value-of select="currency"/></td>
<td><xsl:value-of select="state"/></td>
<td><xsl:value-of select="players"/></td>
<td><xsl:value-of select="blindstructure"/></td>
<td><xsl:value-of select="type"/></td>
<td><xsl:value-of select="limit"/></td>
<td><xsl:value-of select="starttime"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template></xsl:stylesheet>


Here is part of my XML, which is stored on another server:


<?xml version="1.0" encoding="utf-8" ?>
- <xmlfeed>
- <tournament>
<tid>10022248</tid>
<name>Texas Holdem</name>
<game>Texas Holdem Poker</game>
<buyin>10</buyin>
<entryfee>1</entryfee>
<currency>USD</currency>
<state>Running</state>
<players>89</players>
<blindstructure>Normal NL 1</blindstructure>
<type>Regular</type>
<limit>No Limit</limit>
<starttime>2005-11-18T13:00:00</starttime>
</tournament>
.
.
.
- </xmlfeed>


and here is the javascript that pulls the information into the page:


<script type="text/javascript">// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("http://serve.bosscasinos.com/poker/pokerTnFeed_dev.asp?productid=3020")// Load XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("cdcatalog.xsl")// Transform
document.write(xml.transformNode(xsl))</script>


Any ideas as to what might be the problem here?

Thanks folks

J

KC-Luck
11-18-2005, 07:58 PM
what is the error(s) you get?

fogofogo
11-21-2005, 10:51 AM
The error message says "Access denied" and its says the error is in this line:

xsl.load("cdcatalog.xsl")

fogofogo
11-21-2005, 01:03 PM
sorry - the error message is pointing to this line

document.write(xml.transformNode(xsl))

KC-Luck
11-21-2005, 03:41 PM
if the url http://serve.bosscasinos.com/poker/pokerTnFeed_dev.asp?productid=3020 is not within your same domain, you will not be able to access it, via http protocol, hence, the "Access Denied" cross-domain scripting error message.

if it is within same domain:
what about if you break those two lines apart? to see if transform is successful?

var text = xml.transformNode(xsl);
alert( text ); // looks right? gets here?
document.write( text );

fogofogo
11-22-2005, 11:23 AM
Thanks again KC - you are right. The bosscasinos is on another domain.

do you know of a solution to this? My apologies as I am new to XML.

Thanks

J

KC-Luck
11-22-2005, 08:59 PM
it requires some server-side proxy. where another page on your server sends the request and gives back the response;

eg: call to local serverpage, that then goes to the external link, and brings back it's response to your local code.

fogofogo
11-23-2005, 11:01 AM
Thanks again