Re: CS311 Assignment 3 Solution and Discussion
CS311-3-Solution
bc0000000_CS311_S3.html


<!DOCTYPE html>





<html>
<body>
<h1>My Books Collection:</h1>
<button type="button" style="font-size:14px; " onclick="if (!window.__cfRLUnblockHandlers) return false; loadXMLDoc()" data-cf-modified-18337bf230a59fc34ce33f82-=""> Display My Books </button>
<br>
<table id="demo"></table>
<script type="18337bf230a59fc34ce33f82-text/javascript">
	function loadXMLDoc() 		
	{
		var xhttp = new XMLHttpRequest();	
		xhttp.onreadystatechange = function() 
		{
			if (xhttp.readyState == 4 && xhttp.status == 200) {
			myFunction(xhttp);
			}
		};
		xhttp.open("GET", "books_data.xml", true);		
		xhttp.send();
	}

	function myFunction(xml) 		
	{
		var i;
		var xmlDoc = xml.responseXML;
		var table="<br> ";					
		var a = xmlDoc.getElementsByTagName("book");		
		for (i = 0; i <a.length; i++) 
			{	
				<!--getElementsByTagName method and childNodes property-->
			table +="<tr><td>"+a[i].getElementsByTagName("name")[0].childNodes[0].nodeValue+"</td></tr>";
			}
	document.getElementById("demo").innerHTML = table;
	}
</script>
<script src="https://ajax.cloudflare.com/cdn-cgi/scripts/7089c43e/cloudflare-static/rocket-loader.min.js" data-cf-settings="18337bf230a59fc34ce33f82-|49" defer=""></script></body>
</html>