tags:

views:

181

answers:

1

I've got an xml doc that looks similiar to:

<schedule techs="52" date="2009-10-06">

<tech name="Ryan (RI, MA, CT, NH)" value="1">

<time value="4">
<HONAME value="Ronald Baron"/>
<ADDRESS value="35 Liepis rd"/>
<CITY value="Canterbury"/>
<STATE value="CT"/>
<ZIP value="06331"/>
<JOBNUMBER value="33028"/>
<RESULT value="C"/>
<NOTES value=""/>
<BOARD value=""/>
</time>

<time value="9-1">
<HONAME value="Howard McFadzen"/>
<ADDRESS value="77 Crown St. Extension"/>
<CITY value="Meriden"/>
<STATE value="CT"/>
<ZIP value="06450"/>
<JOBNUMBER value="9188"/>
<RESULT value=""/>
<NOTES value="Close ticket 10097792 System keeps sending RF interference and receiver tamper, please fix"/>
<BOARD value="10-1 please"/>
</time>
</tech>
</schedule>

how do i use javascript/jQuery to test for empty nodes? I need to be able to check for several times and if a certain time node such as 1-5 isn't in the xml, i need to beable to run a different function. any ideas?

+1  A: 

Try using the attribute equals selector

if($('time[value=1-5]').length > 0)
{
    // time 1-5 exists
    funcA();
}
else
{
    // time 1-5 doesn't exists
    funcB();
}
bendewey
awesome! i had to modify it slightly to use a for/in loop with vars, but for the most part this worked perfectly, thanks!
mlebrun15
I need to use attribute equals selectors more.
Stefan Kendall