Andromeda
Andromeda

Reputation: 12897

XML parsing Jquery

I have an XML file which has four <resultGroups> tag:

<resultGroups> 
    <subGroups>
        <results> </results>
        <results> </results>
    </subGroups>
    <name> </name>
</resultGroups>

each <resultGroup> has several <subGroups> and each <subGroups> has several <result> tag.

I want to get the no of "results" tag in each subgroups, each resultGroups etc...

How can i do that using jQuery...

Upvotes: 1

Views: 517

Answers (1)

Paolo Bergantino
Paolo Bergantino

Reputation: 488414

$xml = $(xmlString);
$('resultGroups', $xml).each(function() {
    $('subGroups', this).each(function() {
        var count = $('results', this).length;
        // do whatever
    });
});

Upvotes: 3

Related Questions