if (window.XPathEvaluator) { 

    var xpath = new XPathEvaluator(); 

    var element = Element.prototype; 
    var attr = Attr.prototype; 
    var doc = Document.prototype; 

    delete element.text; 
    delete attr.text; 

    element.selectNodes = function (path) { 
        var result = xpath.evaluate(path, this, this.ownerDocument._ns, 7, null); 
        var i, nodes = []; 
        for (i=0; i<result.snapshotLength; i++) { 
            nodes[i] = result.snapshotItem(i); 
            nodes[i].text = nodes[i].firstChild ? nodes[i].firstChild.nodeValue : ""; 
        } 
        return nodes; 
    }; 

    element.selectSingleNode = function (path) { 
       var node = xpath.evaluate(path, this, this.ownerDocument._ns, 9, null).singleNodeValue; 
       dump('element.selectSingleNode(path): ' + path + '\n'); 
       if ( node != null ) node.text = node.firstChild ? node.firstChild.nodeValue : ""; 
       return node; 
    }; 

    doc.selectSingleNode = function (path) { 
        dump('doc.selectSingleNode(path): ' + path + '\n'); 
        var node = xpath.evaluate(path, this, this._ns, 9, null).singleNodeValue; 
        if ( node != null ) node.text = node.firstChild ? node.firstChild.nodeValue : ""; 
        return node; 
    }; 

    doc.selectNodes = function (path) { 
        var result = xpath.evaluate(path, this, this._ns, 7, null); 
        var i, nodes = []; 
        for (i=0; i<result.snapshotLength; i++) { 
            nodes[i] = result.snapshotItem(i); 
            nodes[i].text = nodes[i].firstChild ? nodes[i].firstChild.nodeValue : ""; 
        } 
        return nodes; 
    }; 

} 
