<!-- code adapted from JavaScript the Definintive Guide 5th edition-->

XML = new Object();
XML.newDocument = function()
{	
	//These properties may be used in future versions of xml.js
	var namespaceURL = "";
	var rootTagName = "";
	// documentType is null because there is no browser
	// that supports this arguments as of 9.22.2006.
	var documentType = null;
	
	if(document.implementation && document.implementation.createDocument)
	{
		return document.implementation.createDocument(
					namespaceURL, rootTagName, documentType);
	}
	else // we are in IE
	{
		return new ActiveXObject("MSXML2.DOMDocument");
	}		
}
XML.syncLoad = function(url)
{
	// create new document
	var doc = XML.newDocument();
	doc.async = false;
	doc.load(url);
	return doc;
}
// I realize that this may cause some confusion for 
// developers that are not familure with this class.
// However, everyone knows that string does not have 
// toXML method.  I believe that most developers would
// search xml.js for String.prototype without a second
// thought.
String.prototype.toXML = function()
{
	if(typeof DOMParser != "undefined")
	{
		//We are in Firefox or a compatable browser
		return (new DOMParser()).parseFromString(text, "application/xml");
	}
	else if(typeof ActiveXObject != "undefined")
	{
		// we are in IE
		var doc = XML.newDocument();
		doc.loadXML(this);
		return doc;
	}
	else 	//(safari i guess)
	{
		// here we use a dataurl wich is interesting so its
		// worth coding here just for future reference.
		var url = "data:text/xml;charset=utf-8," + encodeURIComponent(this);
		var request = new XMLHttpRequest();
		request.open("GET", url, async = false);
		request.send(null);
		return request.responseXML;		
	}
}