var  isIE  =   !! document.all;

function  parseXML(st){
        if (isIE){
            var  result  = new ActiveXObject("Microsoft.XMLDOM");
            result.async = false;
            result.load(st);
    } else {
        var result = document.implementation.createDocument("", "", null);
        result.async = false;
        result.load(st);             
    }
        return  result;
}
if (!isIE){
    var  ex;
    XMLDocument.prototype.__proto__.__defineGetter__("xml" ,  function (){
            try {
                return   new  XMLSerializer().serializeToString( this );
        } catch (ex){
                var  d  =  document.createElement( "div" );
            d.appendChild( this .cloneNode( true ));
                return  d.innerHTML;
        }
    });
    Element.prototype.__proto__.__defineGetter__("xml" ,  function (){
            try {
                return   new  XMLSerializer().serializeToString( this );
        } catch (ex){
                var  d  =  document.createElement( "div" );
            d.appendChild( this .cloneNode( true ));
                return  d.innerHTML;
        }
    });
    XMLDocument.prototype.__proto__.__defineGetter__("text",function (){
            return   this.firstChild.textContent
    });
    Element.prototype.__proto__.__defineGetter__("text",function (){
            return   this.textContent
    });
	XMLDocument.prototype.loadXML = function(xmlString)
    {
        var childNodes = this.childNodes;
        for (var i = childNodes.length - 1; i >= 0; i--)
            this.removeChild(childNodes[i]);

        var dp = new DOMParser();
        var newDOM = dp.parseFromString(xmlString, "text/xml");
        var newElt = this.importNode(newDOM.documentElement, true);
        this.appendChild(newElt);
    };
	 XMLDocument.prototype.selectNodes = Element.prototype.selectNodes = function (xpath){
            var  xpe  =   new  XPathEvaluator();
            var  nsResolver  =  xpe.createNSResolver( this.ownerDocument  ==   null   ? 
                this .documentElement :  this.ownerDocument.documentElement);
            var  result  =  xpe.evaluate(xpath, this , nsResolver,  0 ,  null );
            var  found  =  [];
            var  res;
            while  (res  =  result.iterateNext())
            found.push(res);
            return  found;
    }
    XMLDocument.prototype.selectSingleNode = Element.prototype.selectSingleNode = function(xpath){
            var  x = this.selectNodes(xpath)
            if (x.length < 1 ){
				return   null ;
            } else{
				return  x[0];
            }     
    }
   
}