var XDOMNode = Class.create();

XDOMNode.prototype = {
	initialize: function(domNode) {
		this.node = domNode;
	},
	iterator: function(name) {
		return new XDOMIterator(this, name);
	},
	getChild: function(name) {
		return new XDOMNode(this.node.getElementsByTagName(name)[0]);
	},
	getAttribute: function(name) {
		return this.node.getAttribute(name);
	},
	getAttributeAsInt: function(name) {
		return parseInt(this.getAttribute(name));
	},
	getValue: function() {
		return (this.node.firstChild) ? this.node.firstChild.nodeValue : this.node.getAttribute("value");
	},
	getValueAsInt: function() {
		return parseInt(this.getValue());
	}
}

var XDOMIterator = Class.create();

XDOMIterator.prototype = {
	initialize: function(xNode, name) {
		this.name = name;
		this.elements = xNode.node.getElementsByTagName(name);
		this.i = 0;
	},
	hasNext: function() {
		return (this.i < this.elements.length);
	},
	next: function() {
		return new XDOMNode(this.elements[this.i++]);
	}
}
