Hi,
I have the following code from w3schools.
-----------------------------------------------
<html>
<body>
<script type="text/javascript">
function loadXMLDoc(fname)
{
var xmlDoc;
// code for IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation
&& document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}
xmlDoc.async=false;
xmlDoc.load(fname);
return(xmlDoc);
}
///external feed
xml=loadXMLDoc("hxxp://xml.stanjames.com/football-thechampionship.XML");
///my own feed
//xml=loadXMLDoc("feed.xml");
path="/category/event[@name='Sheff Wed v Doncaster']/bettype[@name='Match Betting 90 Minutes']/bet[@had-value='DRAW']/@price";
// code for IE
if (window.ActiveXObject)
{
var nodes=xml.selectNodes(path);
for (i=0;i<nodes.length;i++)
{
document.write(nodes.childNodes[0].nodeValue);
document.write("<br />");
}
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
var nodes=xml.evaluate(path, xml, null, XPathResult.ANY_TYPE,null);
var result=nodes.iterateNext();
while (result)
{
document.write(result.childNodes[0].nodeValue);
document.write("<br />");
result=nodes.iterateNext();
}
}
</script>
</body>
</html>
Now, if i have my own xml file, as follows, it works fine and returns "11/5".
<category>
<event name="Sheff Wed v Doncaster">
<bettype name="Match Betting 90 Minutes">
<bet had-value="DRAW" name="Draw" price="11/5" />
<bet had-value="HOME" name="Barnsley" price="7/4" />
<bet had-value="AWAY" name="Sheff Utd" price="11/8" />
</bettype>
</event>
</category>
However, if i try to use the external url it doesn't work. The external xml is basically set up as above but with more information in it, but it just won't retrieve it and i don't understand why. There's no errors or alerts.
Would anyone have any idea why this would be the case?
please note, i've changed the http to hxxp so it isn't linked within this post.
I have the following code from w3schools.
-----------------------------------------------
<html>
<body>
<script type="text/javascript">
function loadXMLDoc(fname)
{
var xmlDoc;
// code for IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation
&& document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}
xmlDoc.async=false;
xmlDoc.load(fname);
return(xmlDoc);
}
///external feed
xml=loadXMLDoc("hxxp://xml.stanjames.com/football-thechampionship.XML");
///my own feed
//xml=loadXMLDoc("feed.xml");
path="/category/event[@name='Sheff Wed v Doncaster']/bettype[@name='Match Betting 90 Minutes']/bet[@had-value='DRAW']/@price";
// code for IE
if (window.ActiveXObject)
{
var nodes=xml.selectNodes(path);
for (i=0;i<nodes.length;i++)
{
document.write(nodes.childNodes[0].nodeValue);
document.write("<br />");
}
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
var nodes=xml.evaluate(path, xml, null, XPathResult.ANY_TYPE,null);
var result=nodes.iterateNext();
while (result)
{
document.write(result.childNodes[0].nodeValue);
document.write("<br />");
result=nodes.iterateNext();
}
}
</script>
</body>
</html>
Now, if i have my own xml file, as follows, it works fine and returns "11/5".
<category>
<event name="Sheff Wed v Doncaster">
<bettype name="Match Betting 90 Minutes">
<bet had-value="DRAW" name="Draw" price="11/5" />
<bet had-value="HOME" name="Barnsley" price="7/4" />
<bet had-value="AWAY" name="Sheff Utd" price="11/8" />
</bettype>
</event>
</category>
However, if i try to use the external url it doesn't work. The external xml is basically set up as above but with more information in it, but it just won't retrieve it and i don't understand why. There's no errors or alerts.
Would anyone have any idea why this would be the case?
please note, i've changed the http to hxxp so it isn't linked within this post.