[sourcecode language=‘javascript’]
/* ref: https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Processing_XML_with_E4X ref: http://bit.ly/IbKMB prereq: firefox w/ firebug installed and a server running php w/ simplexml note: i’m using a server-side proxy so we can easily make requests to an arbitrary domain usage:
- put this code in an php file called ‘proxy.php’ (or whatever, but make sure the url in the javascript matches)
- upload this file to your server
- run it in firefox
- look for output in console */
var callback = function (text) { var xml = new XML(text);//convert text to an e4x-ready xml object console.log(xml); }, url = ‘proxy.php?run=true’, req = new XMLHttpRequest();
req.open(‘GET’, url, true); req.onreadystatechange = function () { if (req.readyState == 4 && req.status == 200) { callback(req.responseText);//load up xml from proxy as text } }; req.send(null);
[/sourcecode]