Thierry Seunevel Thierry 
Seunevel 
 Tech Corner       
  Home   Missions Tech corner Download Resume Contact
Home > Tech Corner > HTML2XML

XML generation from the content of HTML forms fields (2)

. Principle
. Attributes
. Several forms
. Full Example
. Javascript Code
XML Attributes

To generate some data as attribute instead of element, you just have to add a @ character at the beginning of its name. In the preceding example, if you want to receive the NBPASSADLT and NBPASSENFT elements as attributes NBADULT and NBENFANT you just have to do the following changes.


Changes in the HTML source


....
<td >< input name="@NBADULT" size="5" value="2"/></td>
<td >< input name="@NBENFANT" size="5" value="1"/></td>
....
Resulting XML



<?xml version='1.0'?>
<REQUETE>
<DEMANDE_DISPO>
<DISPONIBILITE NBADULT="2" NBENFANT="1">
<DATE_ALLER>170703</DATE_ALLER>
<DATE_RETOUR>240703</DATE_RETOUR>
<VILLE_DEP>PARIS</VILLE_DEP>
<VILLE_ARRIVEE>TUNIS</VILLE_ARRIVEE>
</DISPONIBILITE>
</DEMANDE_DISPO>
</REQUETE>

    Top  Top  Previous  Principle | Several Forms  Next


©  Thierry Seunevel (2004) www.seusoft.com