All pastes #744903 Raw Edit

Untitled

public text v1 · immutable
·published 2007-10-21 21:47 UTC
rendered paste body
<html>
<head>
<script type="text/javascript">

//global variables
var xmlhttp

//Create the XMLHTTPRequest object.
function loadXMLDoc(url) 
{
	xmlhttp=null
	//Gecko based browsers
	if (window.XMLHttpRequest)
	{
		xmlhttp=new XMLHttpRequest()
	}
	//titan based browsers
	else if (window.ActiveXObject)
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	
	//the object was created
	if (xmlhttp!=null)
	{
		xmlhttp.onreadystatechange=onResponse;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	}
	//the browser doesn't support this!
	else
	{
	alert("Your browser does not support XMLHTTP.")
	}
}

function checkReadyState(obj)
{
	if(obj.readyState == 4)
	{
		if(obj.status == 200)
		{
			return true;
		}
		else
		{
			alert("Problem retrieving XML data");
		}
	}
}

function onResponse() 
{
	if(checkReadyState(xmlhttp))
	{
		var response = xmlhttp.responseXML.documentElement;
		txt="<table border='1'>"
		x=response.getElementsByTagName("CD")
		for (i=0;i<x.length;i++)
		{
			txt=txt + "<tr>"
			xx=x[i].getElementsByTagName("TITLE")
			{
				try
				{
					txt=txt + "<td>" + xx[0].firstChild.data + "</td>"
				}
				catch (er)
				{
					txt=txt + "<td> </td>"
				}
			}
			xx=x[i].getElementsByTagName("ARTIST")
			{
				try
				{
					txt=txt + "<td>" + xx[0].firstChild.data + "</td>"
				}
				catch (er)
				{
					txt=txt + "<td> </td>"
				}
			}
			txt=txt + "</tr>"
		}
		
		txt=txt + "</table>"
		document.getElementById('copy').innerHTML=txt
	}
}
</script>
</head>

<body onLoad="loadXMLDoc('cdCatalog.xml');">

<div id="copy"></div>

</body>
</html>