<html> <head> <script type="text/javascript"> var xmlhttp; function loadXMLDoc(url) { xmlhttp=null; if (window.XMLHttpRequest) {// code for IE7, Firefox, Mozilla, etc. xmlhttp=new XMLHttpRequest(); } else if (window.ActiveXObject) {// code for IE5, IE6 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlhttp!=null) { xmlhttp.onreadystatechange=onResponse; xmlhttp.open("GET",url,true); xmlhttp.send(null); } else { alert("Your browser does not support XMLHTTP."); } } function onResponse() { if(xmlhttp.readyState!=4) return; if(xmlhttp.status!=200) { alert("Problem retrieving XML data"); return; } txt="<table border='1'>"; x=xmlhttp.responseXML.documentElement.getElementsByTagName("cd"); for (i=0;i<x.length;i++) { txt=txt + "<tr>"; xx=x[i].getElementsByTagName("title"); { try { txt=txt + "<td>" + xx[0].firstChild.nodeValue + "</td>"; } catch (er) { txt=txt + "<td> </td>"; } } xx=x[i].getElementsByTagName("artist"); { try { txt=txt + "<td>" + xx[0].firstChild.nodeValue + "</td>"; } catch (er) { txt=txt + "<td> </td>"; } } txt=txt + "</tr>"; } txt=txt + "</table>"; document.getElementById('copy').innerHTML=txt; } </script> </head> <body> <div id="copy"> <button onclick=loadXMLDoc("catalog.xml");>Get CD info</button> </div> </body> </html>
<?xml version="1.0" encoding="UTF-8"?> <!-- Edited with XML Spy v2007 (http://www.altova.com) --> <catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> </cd> <cd> <title>Hide your heart</title> <artist>Bonnie Tyler</artist> </cd> <cd> <title>Greatest Hits</title> <artist>Dolly Parton</artist> </cd> <cd> <title>Still got the blues</title> <artist>Gary Moore</artist> </cd> <cd> <title>Eros</title> <artist>Eros Ramazzotti</artist> </cd> <cd> <title>One night only</title> <artist>Bee Gees</artist> </cd> <cd> <title>Sylvias Mother</title> <artist>Dr.Hook</artist> </cd> <cd> <title>Maggie May</title> <artist>Rod Stewart</artist> </cd> <cd> <title>Romanza</title> <artist>Andrea Bocelli</artist> </cd> <cd> <title>When a man loves a woman</title> <artist>Percy Sledge</artist> </cd> <cd> <title>Black angel</title> <artist>Savage Rose</artist> </cd> <cd> <title>1999 Grammy Nominees</title> <artist>Many</artist> </cd> <cd> <title>For the good times</title> <artist>Kenny Rogers</artist> </cd> <cd> <title>Big Willie style</title> <artist>Will Smith</artist> </cd> <cd> <title>Tupelo Honey</title> <artist>Van Morrison</artist> </cd> <cd> <title>Soulsville</title> <artist>Jorn Hoel</artist> </cd> <cd> <title>The very best of</title> <artist>Cat Stevens</artist> </cd> <cd> <title>Stop</title> <artist>Sam Brown</artist> </cd> <cd> <title>Bridge of Spies</title> <artist>T`Pau</artist> </cd> <cd> <title>Private Dancer</title> <artist>Tina Turner</artist> </cd> <cd> <title>Midt om natten</title> <artist>Kim Larsen</artist> </cd> <cd> <title>Pavarotti Gala Concert</title> <artist>Luciano Pavarotti</artist> </cd> <cd> <title>The dock of the bay</title> <artist>Otis Redding</artist> </cd> <cd> <title>Picture book</title> <artist>Simply Red</artist> </cd> <cd> <title>Red</title> <artist>The Communards</artist> </cd> <cd> <title>Unchain my heart</title> <artist>Joe Cocker</artist> </cd> </catalog>