tags:

views:

95

answers:

1
+1  Q: 

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...

+3  A: 
$xml = $(xmlString);
$('resultGroups', $xml).each(function() {
    $('subGroups', this).each(function() {
        var count = $('results', this).length;
        // do whatever
    });
});
Paolo Bergantino
thnk u for tht.....If u don't mind can u just give me different approaches or methods possible on an XMl using jquery???
Jasim
I'm not sure what you mean? You can do any traversing you want, get attributes, set attributes... just read up on the jQuery documentation.
Paolo Bergantino