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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Document sans titre</title>
<style type="text/css">
<!--
.Style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
}
.Style2 {font-family: Verdana, Arial, Helvetica, sans-serif}
-->
</style>
</head>
<body>
<?php
if(isset($_POST['action'])) $action=$_POST['action']; else $action="inconnue";
if($action=="ecriture") {
############################################################ECRITURE
//Initialisation des variables envoyées par le formulaire
if(isset($_POST['URL'])) $URL=$_POST['URL']; else $URL="URL inconnu";
if(isset($_POST['titre'])) $titre=$_POST['titre']; else $titre="titre inconnu";
//---------------------------------
$fp= fopen("liste.xml", "a");//ouverture du fichier XML
$Liste=$doc_xml->getElementsByTagName('Liste');
foreach($Liste as $Liste){
$fichier_xml ="\t<Music URL=\"$URL\">$titre</Music>\r\n";
}
//-------------------------------------------------------------------------------------
fwrite($fp, $fichier_xml);//ecriture du fichier
fclose($fp);//fermeture du fichier
// header("Location:liste.xml");
############################################################FIN D'ECRITURE
}//fin du IF
?>
</p>
<form name="form1" method="POST" action="ecritureXml3.php">
<table width="500" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td><div align="center">
<table width="496" border="0" cellspacing="0" cellpadding="5">
<tr>
<td colspan="2"><div align="center" class="Style1">ECRITURE
D'UN FICHIER XML </div></td>
</tr>
<tr>
<td width="248"><div align="right" class="Style2">Titre :
</div></td>
<td width="248"><input name="titre" type="text" id="titre" ></td>
</tr>
<tr>
<td><div align="right" class="Style2">Fichier : </div></td>
<td><input type="file" name="URL" id="URL" ></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Envoyer">
<input name="action" type="hidden" id="action" value="ecriture">
</div></td>
</tr>
</table>
</div></td>
</tr>
</table>
<p align="center"> </p>
<p> </p>
</form>
<a href="liste.xml" > Voir le fichier XML avant l'écriture </a>
</body>
</html> |
Partager