// File: readXML.js

// Start function when DOM has completely loaded 
$(document).ready(function(){ 

	// Open the post.xml file
	$.get("http://www.virginia.edu/mediastudies/news/feeds/posts/atom.xml",{},function(xml){
      	
		// Build an HTML string
		myHTMLOutput = '';
	 	myHTMLOutput += '<dl>';
	  	
		
	// Run the function for each post tag in the XML file
	
	i = 0
	$('entry',xml).each(function(i) {
			i ++
			title = $(this).find("title").text();
			postlink = $(this).find("[rel='alternate']").attr("href");
			name = $(this).find("name").text();
		
			
		
			mydata = BuildStudentHTML(title,name);
			myHTMLOutput = myHTMLOutput + mydata;
			if (i > 4){
				return false;
			}
		});
		myHTMLOutput += '</dl>';
		
		// Update the DIV called Content Area with the HTML string
		$("div.blogoutput").append(myHTMLOutput);});
	});
 function BuildStudentHTML(title,name){
	

		studentPostHTML = "";
	
	
	// Build HTML string and return
	output = '';
	
	output += '<dt><a href="' + postlink + '">' + title + '</a></dt>';
	output += '<dd><em>'+ name +'</em></dd>';
	return output;
}
	 