function XParser(xmlDocument) {

	this.evaluate = evaluate;
	this.evaluateAttribute = evaluateAttribute;
	this.evaluateNodeValue = evaluateNodeValue;
	this.evaluateCount = evaluateCount;
		
	var ie = document.all;
	
	function evaluate(xpath, contextNode) {
		if (!contextNode) {
			contextNode = xmlDocument;
		}
		var myNodes = new Array();
		if (ie) {
			myNodes = contextNode.selectNodes(xpath);
		}
		else {
			var xpathResult = xmlDocument.evaluate(xpath, contextNode, null, XPathResult.ANY_TYPE, null);
			var myNode = xpathResult.iterateNext();
			while (myNode) {
				myNodes.push(myNode);
				myNode = xpathResult.iterateNext();
			}
		}
		
		return myNodes;	
	}
	
	function evaluateAttribute(xpath, attribute, contextNode) {
		var attributeValue = null;
		var myNodes = evaluate(xpath, contextNode);
		if (myNodes[0]) {
			attributeValue = myNodes[0].getAttribute(attribute);
		}
		return attributeValue;
	}
	
	function evaluateNodeValue(xpath, contextNode) {
		var value = "";
		var myNodes = evaluate(xpath, contextNode);
		if (myNodes[0]) {
			if (myNodes[0].firstChild) {
				value = myNodes[0].firstChild.nodeValue;
			}
		}
		return value;
	}
	
	function evaluateCount(xpath, contextNode) {
		var myNodes = evaluate(xpath, contextNode);
		return myNodes.length;
	}
		
		
		
	
	
	
}