I am parsing XML using jQuery. I want to get a count of all nodes with the specified tag name.
For instance:
<People>
<person name="hello'></person>
<person name="hello'></person>
<person name="hello'></person>
<person name="hello'></person>
<person name="hello'></person>
</people>
I am using the following jQuery code:
$(xml).find("person").each(function(){});
Of course, the above code works, but I just want to get a counter, I don't want it to work. The reason is that the above example is too simple, my XML file and javascript code are a bit complicated, so there is a lot of logic to define an XML file, and I don't want to waste code writing all of this.
Many thanks!
source
share