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??
EDIT:
Found a way to make it work thanks to @Regent and @mehsen.
I needed to get the file in a different way if on browser or device as said here, and then, one I have the file, read it as said here and here.