

//this function will take the xmlDoc and parse it into an array
//returns: the array of parseed xml
function parseXML()
{
	// initiate variables
	var contacts = xmlDoc.getElementsByTagName("contact");
	contactsArray = new Array();
	
	//build the array of projects
	for ( i = 0; i < contacts.length; i++)
	{
		var tempArray = new Array();
		
		// search for specific tags
		var firstA = contacts[i].getElementsByTagName("First");
		var lastA = contacts[i].getElementsByTagName("Last");
		var titleA = contacts[i].getElementsByTagName("Title");
		var departmentA = contacts[i].getElementsByTagName("Department");
		var phoneA = contacts[i].getElementsByTagName("Phone");
		var emailA = contacts[i].getElementsByTagName("email");
		
		
		
		if(firstA.length > 0){
			tempArray['first'] = firstA[0].childNodes[0].nodeValue;
		}else{
			tempArray['first'] = "N/A";
		}
		
		if(lastA.length > 0){
			tempArray['last'] = lastA[0].childNodes[0].nodeValue;
		}else{
			tempArray['last'] = "N/A";
		}
		
		if(titleA.length > 0){
			tempArray['title'] = titleA[0].childNodes[0].nodeValue;
		}else{
			tempArray['title'] = "N/A";
		}
		
		if(departmentA.length > 0){
			tempArray['department'] = departmentA[0].childNodes[0].nodeValue;
		}else{
			tempArray['department'] = "N/A";
		}
		
		if(phoneA.length > 0){
			tempArray['phone'] = phoneA[0].childNodes[0].nodeValue;
		}else{
			tempArray['phone'] = "N/A";
		}
		
		if(emailA.length > 0){
			tempArray['email'] = emailA[0].childNodes[0].nodeValue;
		}else{
			tempArray['email'] = "N/A";
		}
		
		//add the temp array to the contactsArray 
		contactsArray.push(tempArray);
	}//end of for ( i = 0; i < projects.length; i++)
	return contactsArray;
}// end of parseXML

