Tuesday, 15 February 2011

javascript - Parsing part of a XML file with jQuery -



javascript - Parsing part of a XML file with jQuery -

after receiving "day" text input, how can display <product> of <availabilities>, same date using jquery? maybe utilize of .siblings() ?

<?xml version='1.0' encoding='iso-8859-15'?> <timetable> <date> <day>22-01-2013</day> <availabilities> <availability> <starttime>10:00</starttime> <endtime>13:00</endtime> <startplace>funchal</startplace> <endplace>funchal</endplace> <resource>excursões na madeira</resource> <idstartplace>18</idstartplace> <idendplace>18</idendplace> <idperiodoconsumo>13289</idperiodoconsumo> <idproduct>23</idproduct> <product>exc_sant</product> <idtimeperiod>11523</idtimeperiod> <idavailability>3561</idavailability> </availability> <availability> <starttime>10:00</starttime> <endtime>13:00</endtime> <startplace>funchal</startplace> <endplace>funchal</endplace> <resource>excursões na madeira</resource> <idstartplace>18</idstartplace> <idendplace>18</idendplace> <idperiodoconsumo>13290</idperiodoconsumo> <idproduct>33</idproduct> <product>foot</product> <idtimeperiod>11524</idtimeperiod> <idavailability>3593</idavailability> </availability> <availability> <starttime>10:00</starttime> <endtime>13:00</endtime> <startplace>funchal</startplace> <endplace>funchal</endplace> <resource>excursões na madeira</resource> <idstartplace>18</idstartplace> <idendplace>18</idendplace> <idperiodoconsumo>13289</idperiodoconsumo> <idproduct>22</idproduct> <product>vlt_ilha</product> <idtimeperiod>11523</idtimeperiod> <idavailability>3561</idavailability> </availability> </availabilities> </date> <date> ... </date> ...

here's sucess: function:

function parsestuff(data){ $(data).find('date').each(function(){ var day = $(this).find('day').text(); if (day==decodeuri(ihash[3])){ alert('date matches!'); } }); }

i'd appreciate help, have no thought how this.. :|

try one:

var product = $(this).find('product').text();

i think have set here:

if (day==decodeuri(ihash[3])){ var product = $(this).find('product').text(); alert('date matches!'); }

javascript jquery xml xml-parsing

No comments:

Post a Comment