I have an XML structure like the following: <item> <attr1>1</attr1> <attr2>2</attr2> <attr3>3</attr3> </item>
This XML gets returned to me after an ajax post, so I can get the tags using: $(xml).find('item').each(function() { var 1 = $(this).children('attr1').text(); var 2 = $(this).children('attr2').text(); } But, what if I don't want to set those into vars, but push each attribute into an array, even if I don't know the name? Also, could I push them into an associative array so that I the name/value pairs are together? Thanks!