DPXmlReader = {
	xml_parser: null,

	xml_doc: null,

	create: function() {
		if( !DPXmlReader.xml_doc && !DPXmlReader.xml_parser ) {
			if( window.ActiveXObject ) {
				DPXmlReader.xml_doc = new ActiveXObject("Microsoft.XMLDOM");
				DPXmlReader.xml_doc.async = "false";
			}
			else {
				DPXmlReader.xml_parser = new DOMParser();
			}
		}
	},

	read: function(xml) {
		if( !DPXmlReader.xml_doc && !DPXmlReader.xml_parser ) {
			DPXmlReader.create();
		}

		if( window.ActiveXObject ) {
			DPXmlReader.xml_doc.loadXML(xml);
		}
		else if( document.implementation && document.implementation.createDocument ) {
			DPXmlReader.xml_doc = DPXmlReader.xml_parser.parseFromString(xml, 'text/xml');
		}

		return DPXmlReader.xml_doc;
	},

	get: function() {
		var count = arguments.length;
		var doc = DPXmlReader.xml_doc;
		
		if( !count || !doc ) {
			return null;
		}

		for( var i = 0; i < count; i++ ) {
			var arg = arguments[i];
			doc = doc.getElementsByTagName(arg);
			if( doc && doc.length && doc[0] && doc[0].childNodes ) {
				doc = doc[0];
				if( i == count - 1 ) {
					return doc.childNodes[0].nodeValue;
				}
			}
			else {
				return null;
			}
		}

		return null;
	}
}

