1 pièce(s) jointe(s)
Extraire les données d'un tableau html dans un xml
Bonjour !!
d'abord désolé, je ne savais vraiment pas où poster le sujet :s
voilà mon problème, j'ai crée un tableau en html à deux entrées et j'aimerais pouvoir extraire les donnée dans un fichier xml.
Pour que j'arrive mieux à vous expliquer je vous ai fait une maquette de mon tableau :)
Pièce jointe 138898
Voilà alors ce que je voudrai faire c'est dire quand dans tel ou tel trip il y a tel ou tel personnes, le xml donnerai ça :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| <trip name="Trip1">
<participants id="0" prenom="Pauline" />
<participants id="3" prenom="Sophia" />
<participants id="5" prenom="Pierre" />
</trip>
<trip name="Trip2">
<participants id="1" prenom="Jean" />
<participants id="2" prenom="Eric" />
<participants id="3" prenom="Sophia" />
</trip>
<trip name="Trip3">
<participants id="0" prenom="Pauline" />
<participants id="2" prenom="Eric" />
<participants id="3" prenom="Sophia" />
<participants id="4" prenom="Nathalie" />
</trip> |
Voilà et le html est construit de cette façon :
Code:
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
| <table>
<thead>
<tr>
<td></td>
<td></td>
<td>Trip1</td>
<td>Trip2</td>
<td>Trip3</td>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>Pauline</td>
<td><input type="checkbox" name="trip1" value="0" /></td>
<td><input type="checkbox" name="trip2" value="0" /></td>
<td><input type="checkbox" name="trip3" value="0" /></td>
</tr>
<tr>
<td>1</td>
<td>Jean</td>
<td><input type="checkbox" name="trip1" value="1" /></td>
<td><input type="checkbox" name="trip2" value="1" /></td>
<td><input type="checkbox" name="trip3" value="1" /></td>
</tr>
<tr>
<td>2</td>
<td>Eric</td>
<td><input type="checkbox" name="trip1" value="2" /></td>
<td><input type="checkbox" name="trip2" value="2" /></td>
<td><input type="checkbox" name="trip3" value="2" /></td>
</tr>
</tbody>
</table> |
et voilà ce que j'ai commencé à faire avec dom php :
Code:
1 2 3 4 5 6 7 8 9 10 11
| for($i=0; $i<100; $i++){
if (isset($_POST['trip'.$i])){
$trip = $dom->createElement('trip');
$particpant= $dom->createElement('participant');
$idPart = $dom->createAttribute('id');
$idPart->value = $_POST['trip'.$i];
$participant->appendChild($idPart);
$trip->appendChild($participant);
$tripList->appendChild($trip);
}
} |
j'ai créer au dessus un noeud Trip list, le truc c'est qu'avec le code que j'ai fait ca va créer un nouveau trip à chaque fois, alors qu'il faudrai créer une boucle pour les trip puis une boucle pour les participants, mais là je bloque un peu ....
Merci beaucoup pour votre aide !!!