Phonegap: How to read and parse a local XML in browser



I'm trying to read an xml file so I can learn how to, I have my test xml file in local and I'm trying to open and parse it.


All I find when I google for info is people asking how to solve their problems when parsing, but none of them explains how to open the file in first place.


I found this code:



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","entrada.xml",false);
xmlhttp.send();
xmlDoc = xmlhttp.responseXML;


But when testing on browser (Chrome) I get this error:



XMLHttpRequest cannot load file:///Users/.../cursos/www/entrada.xml. Cross origin requests are only supported for HTTP.
Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///Users/.../cursos/www/entrada.xml'.


I don't want to use a device if can avoid. How can I test it on browser??


No comments:

Post a Comment