How do check 'roster' has no child values using javascript
<club code="3RD1" tvcode="">
<name>3RD PLACE TEAM 1</name>
<roster/>
</club>
<club code="3RD1" tvcode="">
<name>3RD PLACE TEAM 1</name>
<roster>
<player code="AUQ"/>
</roster>
</club>
if you can use jquery,
you can parse this by using $.parseXML
xmlDoc = $.parseXML( "<xml></xml>" );
and then you can use find
to get the prefered node
$(xmlDoc).find("roster")
and get number of children via
.children().length
putting it together
var rostersChildren = $(xmlDoc).find("roster").children().length;
console.log(rostersChildren > 0);
here is a sample fiddle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With