I have the following XML to be processed:
<doc>
<status></status>
<value>
<form>
<field type = "input" name = "organisation" description =
"Organisatie" />
<field type = "select" name = "organisationType" description = "Soort
Organisatie">
<option value = "geen" />
<option value = "Non Profit" />
<option value = "ZZP" />
<option value = "MKB" />
<option value = "Anders" />
</field>
<field type = "input" name = "firstName" description = "Voornaam" />
<field type = "input" name = "lastName" description = "Achternaam" />
<field type = "input" name = "email" description = "E-mail" />
<field type = "input" name = "telephone" description = "Telefoon" />
<field type = "input" name = "address" description = "Adres" />
<field type = "input" name = "zipcode" description = "Postcode" />
<field type = "input" name = "city" description = "Plaats" />
<field type = "select" name = "reason" description = "Reden Voor
Contact">
<option value = "geen" />
<option value = "Vraag" />
<option value = "Opmerking" />
<option value = "Verzoek Om Informatie" />
<option value = "Neem Contact Met Mij op" />
</field>
<field type = "textarea" name = "description" description =
"Omschrijving" />
</form>
</value>
<duration>Uitvoeren van het script duurde 21.371 milisec</duration>
</doc>

I process it with the folowing code:
    $.post(cgiURL,
      {command: "getForm", form: cgiForm},
      function(xml){
        $(xml).find('field').each(function() {
          if( $(this).attr('type') == 'input' ) {

Is there a better way to do this?
There a severall 'problems'.
There should be exactly one form.
Only the field records that are immediate descendants of form should
be used. When there comes another type which also has children with
type field, this code will process those also.

Reply via email to