playing with e4x in firefox: loading arbitrary xml as an e4x-ready object


/*
ref: https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Processing_XML_with_E4X
prereq: firefox w/ firebug installed and a server running php w/ simplexml
usage:
1) put this code in an php file
2) upload this file to your server
3) run it in firefox
4) look for output in console
*/
var xml = new XML(
	<?php
	$url = 'http://query.yahooapis.com/v1/public/yql?q=show%20tables&format=xml';
	$sxml = simplexml_load_file($url);
    //strip off the xml declaration because the javascript XML() object expects raw xml
	echo str_replace('', '', $sxml->asXML());
	?>
);
console.log(xml);