﻿//Se crea el objeto ajax para poder leer los xml
function fn_ajax() 
{
        try { // Esto es para IExplorer
                ajax = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
                try {
                        ajax= new ActiveXObject("Microsoft.XMLHTTP");
                } catch (E) {
                        ajax= false;
                }
        }
        if (!ajax && typeof XMLHttpRequest!='undefined') { // y para Mozilla o Safari
                ajax = new XMLHttpRequest();
        }
        return ajax
}
function xmlgetdata(sreq)
{
	var root;
	xmlDoc = fn_ajax();
	xmlDoc.open("GET",sreq,false); //Abrimos la conexion
	xmlDoc.send(null);
	
	// Obtener la Etiqueta padre (tabla)
	// Nota el nombre de las etiquetas no da lo mismo mayusculas y minusculas.
	if(xmlDoc.status!=200)
	{
	  alert("Error: "+xmlDoc.status+" - No se puede obtener el nodo raiz -")
	}
	else
	{
	  	root = xmlDoc.responseXML.getElementsByTagName('ROOT')[0];// Obtener el primer nodo de la raiz.	
		if (root.tagName == "OK")
		{
			alert('VACIO');	
		}
		else
		{
			
			return root;	
		}
	}	
}
