我正在使用以下 XML 文件
<OnThisDate date="2013-02-22">
<event jobnumber="14434" allocated="1" name="ADI UK ">
<i1001 driverID="30" driverName="None None" groupname="i100"/>
<i251 driverID="0" driverName="" groupname="i25"/>
<i252 driverID="0" driverName="" groupname="i25"/>
</event>
<event jobnumber="14559" allocated="1" name="Travel">
<i1006 driverID="46" driverName="Martin Macklin" groupname="i100"/>
</event>
<event jobnumber="14560" allocated="1" name="Travel">
<i1005 driverID="0" driverName="" groupname="i100"/>
</event>
<event jobnumber="14690" allocated="1" name="Travel">
<i253 driverID="0" driverName="" groupname="i25"/>
</event>
<event jobnumber="14695" allocated="1" name="Holiday">
<i602 driverID="10" driverName="Alan Linney " groupname="i60"/>
</event>
<event jobnumber="13595" allocated="1" name="Sandown Park Racecourse">
<i1002 driverID="6" driverName="Simon Latcham" groupname="i100"/>
</event>
<event jobnumber="14447" allocated="1" name="Sandown Racecourse">
<i125 driverID="35" driverName="Carl Boxall" groupname="i12"/>
</event>
<event jobnumber="14030" allocated="1" name="Warwick Racecourse">
<i601 driverID="5" driverName="Tom Robson" groupname="i60"/>
</event>
</OnThisDate>
每个事件下的节点都有一个groupname属性,我想按 group name 获得总结果,所以在示例中 groupname i25 的总和为 3
我已经能够使用此代码获得事件子项的总和
var count=$(data).find('event').children().size();
console.log(count)
但我不知道如何让它其余的工作
请问有什么帮助吗?, 提前致谢