
// ========================================================================
// PARSING
// ========================================================================
function Parsing(xml) {

	// ========================================================================
	// CONSTRUTOR
	// ========================================================================
	try //Internet Explorer
	{
		this.xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		this.xmlDoc.async="false";
		this.xmlDoc.loadXML(xml);
	}
	catch(e)
	{
		try //Firefox, Mozilla, Opera, etc.
		{
			this.parser=new DOMParser();
			this.xmlDoc=this.parser.parseFromString(xml,"text/xml");
		}
			catch(e) {alert(e.message)}
	}
	// ========================================================================
	// GET NODO (Retorna o nodo em questão)
	// ========================================================================
	this.GetNodo = function(nodo) {
		try{
			return (this.xmlDoc.getElementsByTagName(nodo));
		} catch(e){
			alert("Nodo '" + nodo + "' não encontrado \nXML:\n" + xml + "\nDEBUG: " + e.message );
		}
	}
	// ========================================================================
	// GET ATTR (retorna do primeiro filho sempre)
	// ========================================================================
	this.GetAttr = function(attr) {

		try{
			return (this.xmlDoc.getElementsByTagName(attr)[0].childNodes[0] ? this.xmlDoc.getElementsByTagName(attr)[0].childNodes[0].nodeValue : '');
		} catch(e){
			alert("Atributo '" + attr + "' não encontrado \nXML:\n" + xml + "\nDEBUG: " + e.message );
		}

	}
}

// ========================================================================
// Sem Parcing
// ========================================================================
function XmlDoc(xmlDoc) {

	// ========================================================================
	// GET NODO (Retorna o nodo em questão)
	// ========================================================================
	this.GetNodo = function(nodo) {
		try{
			return (xmlDoc.getElementsByTagName(nodo));
		} catch(e){
			alert("Nodo '" + nodo + "' não encontrado \nDEBUG: " + e.message );
		}

	}
	// ========================================================================
	// GET ATTR (retorna do primeiro filho sempre)
	// ========================================================================
	this.GetAttr = function(attr) {
		try{
			return (xmlDoc.getElementsByTagName(attr)[0].childNodes[0] ? xmlDoc.getElementsByTagName(attr)[0].childNodes[0].nodeValue : '');
		} catch(e){
			alert("Atributo '" + attr + "' não encontrado \nDEBUG: " + e.message );
		}

	}
}
