1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>">
<html xmlns="<a href="http://www.w3.org/1999/xhtml" target="_blank">http://www.w3.org/1999/xhtml</a>">
<head>
<title>Liste des commandes</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script language="JavaScript">
function getXhr(){
if(window.XMLHttpRequest) // Firefox et autres
xhr = new XMLHttpRequest();
else if(window.ActiveXObject){ // Internet Explorer
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
}
else { // XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr = false;
}
}
function xmltxt(){
getXhr();
xhr.onreadystatechange = function(){
if(xhr.readyState == 4 && xhr.status == 200){
getLivres(xhr.responseXML,"Voltaire");
alert(liste);
}
}
xhr.open("GET", "livre.xml", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(null);
}
function getLivres(var XML, var autor)
{
var DOM_XML = document.createElement('div');
DOM_XML.innerHTML = XML;
var autors = DOM_XML.getElementsByTagName('livres');
var results = new Array();
for(var i = 0; i < autors.length; ++i)
if(autors[i].getAttribute('auteur') == autor)
{
var livres = autors[i].getElementsByTagName('livre');
for(var j = 0; j < livres.length; ++j)
result.push(livres[i].innerHTML);
}
return result;
}
</script>
</head>
<body onLoad="xmltxt();">
</body>
</html> |