so I need to load the data from a xml file and then print it in a console...
For now im only taking the xml directly like this:
var xml = '<?xml version="1.0" encoding="UTF-8"?><Person><Name></Name></Person>'
var xmlDoc = $.parseXML( xml );
var $xml = $(xmlDoc);
But what I would like to do is instead pasting the xml file directly, to paste only the location to it, for example:
var xml = "C:User/xmls/example.xml";
You could use an XMLHttpRequest()
to get the file using its url.
var x = new XMLHttpRequest();
x.open("GET", "http://yoururl.com");
x.onreadystatechange = function () {
if (x.readyState == 4 && x.status == 200)
{
var doc = x.responseXML; // Contains your requested document
}
};
x.send(null);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.