I am working in an iPhone app in HTML. It needs to retrieve content from an xml stored in a remote server and show its content in a list.
I have already achieved this when the xml file is stored in the same server with this code:
<body>
<div id="container">
<div id="header">
<h1><a href="./">BurgerFast</a></h1>
<p>Menú</p>
<div>
<div id="nav">
<ul>
<span id="lista"></span>
</ul>
</div>
<div id="footer">
<ul>
<li><a href="/assets/cl.png">Acerca de</a></li>
<li><a href="/assets/cl.png">Ayuda</a></li>
</ul>
</div>
</div>
</div>
</div>
<script type="text/javascript">
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","assets/note.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var item = xmlDoc.getElementsByTagName("item")
var myElems = "";
for(i = 0 ; i < item.length ; i++){
myElems = myElems + "<li><a>" + item[i].getElementsByTagName("name")[0].childNodes[0].nodeValue + "</li></a>";
}
document.getElementById("lista").innerHTML = myElems;
</script>
</body>
So far, no problem. As the file is hosted in the same server works nicely, but I want to be able to load xml from different servers but mine. When I change the line:
xmlhttp.open("GET","assets/note.xml",false);
and leave itlike this:
xmlhttp.open("GET","http://173.236.56.146/~crayonli/xml/note.xml", true);
it tells me everytime the xmldoc is null, I don't get it, it's the same damn xml.
I just cannot see where's my mistake. Can somebody tell?