function createXMLDoc(dname) {
	var xmlDoc = null;
	if (window.ActiveXObject) {
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async = false;
		if (typeof(dname) != "undefined") xmlDoc.load(dname);
	} else if (document.implementation &&	document.implementation.createDocument) {
		xmlDoc = document.implementation.createDocument("", "", null);
		xmlDoc.async = false;
		if (xmlDoc.load) {
			if (typeof(dname) != "undefined") xmlDoc.load(dname);
		} else { 
			if (typeof(dname) == "undefined") dname = "";
			var httpReq = new XMLHttpRequest();
			httpReq.open("GET", dname, false);
			httpReq.send(null);
			xmlDoc = httpReq.responseXML;
		}
	}
  return xmlDoc;
}

//retrieves an xml object fill with all he elements nodes of xmlNode
function getElementChildNodes(xmlNode){
	var childNode;
	var childs;alert(xmlNode.tagName);
	if(xmlNode.childNodes.length >0){
		var docXML = createXMLDoc();
		if(docXML != null){
			
			childs = docXML.createElement(xmlNode.tagName);
				//alert('hijos originales '+ xmlNode.childNodes.length);
			var cant = 0;
			for (i=0; i < xmlNode.childNodes.length; i++)
			{
				childNode = xmlNode.childNodes[i];
				if(childNode.nodeType==1){
					//we need to create a new node element to apped to the childs object
					childs.appendChild(childNode.cloneNode(true));
				}
			}
				//alert('hijos elementos '+ childs.childNodes.length);
			if(childs.childNodes.length>0){
				return childs;
			}
		}
	}
	return null;
}

//retrieve the element node in childIndex position (supose the element nodes as a vector)
function getElementChild(xmlNode, childIndex){
	var elementNodeCount = 0;
	var childNode = null;
	for (i=0; i < xmlNode.childNodes.length; i++)
			{
				childNode = xmlNode.childNodes[i];
				if(childNode.nodeType==1){
					elementNodeCount++;
					if(elementNodeCount = (childIndex+1)){
						return childNode;
					}
				}
			}
	//if there is lees elements than the childIndex, retrieve null
	return null;
}
