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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="fr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
function Action(xmlDoc)
{
var record = xmlDoc.getElementsByTagName('record'); //Array des record
var nom = xmlDoc.getElementsByTagName('nom'); //Array des noms
var prenom = xmlDoc.getElementsByTagName('prenom'); //Array des prénoms
var div = document.getElementById('xml');
//Modification de la table
var table = div.appendChild('table');
//Entete
tr = table.appendChild('tr');
for(i = 0 ; i < record[0].childNodes.length ; i++) //On compte le nombre de champ par record
{
th = tr.appendChild('th');
th.nodeValue(i);
}
//Corps
tr = table.appendChild('tr');
for(i = 0 ; i < record.length ; i++) //On compte le nombre de record
{
td = tr.appendChild('td');
td.nodeValue(nom[i]);
}
}
</script>
</head>
<body>
<input type="button" onclick="caca();" value="Créer Table" />
<div id="xml">
</div>
</body>
</html> |
Partager