get <rs:data ItemCount>

Jan 10, 2012 at 4:40 AM
Edited Jan 10, 2012 at 4:41 AM

GetListItems returns all the selected row nodes wrapped in a <data> element and I want to grab the ItemCount attribute of that <data> element using javascript (in the completefunc).

This is going to be simple, but my brain isn't working today.

The xPath would be: 


Jan 10, 2012 at 4:45 AM

Here's an example straight from SPServices itself:

// Get the count of items returned and save it so that we can select if it's a single option 
// The item count is stored thus: <rs:data ItemCount="1">
numChildOptions = parseFloat($(xData.responseXML).SPFilterNode("rs:data").attr("ItemCount"));


Jan 10, 2012 at 4:54 AM

Thanks, Marc. Should have mentioned I'm using v0.6.2, but you lead me in the right direction nontheless. If anyone else has a similar brain snap:

var totalRows = parseFloat($(xData.responseXML).find('[nodeName="rs:data"]').attr("ItemCount"));

...will work with versions up to 0.6.2 of SPServices