function stripXMLHeader( xml ){
	var start_pos = xml.indexOf("<return");
	var end_pos = xml.indexOf("/return>") + 8;	// Find the END of the </return>
	var length = end_pos - start_pos;
	
	// Just the good stuff of the XML_String
	var xml_string = xml.substr( start_pos, length );
	return xml_string;
}

function cleanXML( xml_string ){
	reg_ex = /<[a-z0-9_]* /;
	var new_string = xml_string;
	
	count = 0;	// Just incase
	// Only loop 1000 times. If you're missing some of your XML, come here and make that number larger.
	while( reg_ex.test( new_string )  && count < 100000){	// Keep going until all the crap is cleared out
		res = reg_ex.exec( new_string );
		start = res.index;
		
		// Find the start of the element to clear out
		end = new_string.indexOf( " ", start );
		end_element = new_string.indexOf( ">", end );
		
		// However if the xsi:nil="true" , then end the element
		//<prefix xsi:nil="true" xsi:type="xsd:string"/>		
		check_null_string = new_string.substring( 0, end_element );
		if( check_null_string.indexOf( 'xsi:nil="true"' ) >-1 ){
			old_string = new_string.substring( 0, end ) + "/";	//	<prefix
		}else{		
			old_string = new_string.substring( 0, end );	//<oms_known_as
		}
		new_string = new_string.substring( end_element ); // Everything else
			
		new_string = old_string + new_string;			
				
		++count;
	}
	return( new_string );
}

var objStripXML = function( xmlObj ){
	var start_pos = xmlObj.xml.indexOf("<return");
	var end_pos = xmlObj.xml.indexOf("/return>") + 8;	// Find the END of the </return>
	var length = end_pos - start_pos;
	
	xmlObj.xml = xmlObj.xml.substr( start_pos, length );
	objCleanXML( xmlObj );
}

var objCleanXML = function( xmlObj ){
	reg_ex = /<[a-z0-9_]* /;
	//var new_string = xmlObj.xml;
	
	count = 0;	// Just incase

	var new_string = xmlObj.xml;
	while( reg_ex.test( new_string ) ){
		res = "" + reg_ex.exec( new_string );
		res = res.replace(" ","");
		end_element = new_string.indexOf( ">", res.index );
		dirty_filthy = new_string.substr( res.index, end_element );
		new_string = new_string.replace( dirty_filthy, res );
	}
	alert( new_string );
	xmlObj.xml = new_string;
	//////////////////////////////////////////////
	//
	////		THIS REGEX	//
	//						^<return.+[>]$

	//}
	// while( reg_ex.test( new_string )  && count < 100000){	// Keep going until all the crap is cleared out
		// res = reg_ex.exec( new_string );
		// start = res.index;
		
		//Find the start of the element to clear out
		// end = new_string.indexOf( " ", start );
		// end_element = new_string.indexOf( ">", end );
		
		// old_string = new_string.substring( 0, end );
		// new_string = new_string.substring( end_element );
		// new_string = old_string + new_string;
		
		// ++count;
	// }
}

XML_Object = function( xml_doc ){
	if (window.DOMParser){
		parser=new DOMParser();
		xmlDoc=parser.parseFromString(xml_doc,"text/xml");
	}else{ // Internet Explorer
	  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	  xmlDoc.async="false";
	  xmlDoc.loadXML(xml_doc); 
	} 
	return xmlDoc;
}
