如何遍历xml中的所有标记
<register> <name>peter</name> <age>12</age> </register> <register> <name>mary</name> <age>20</age> </register>
所以我收到这个xml(这很好)
$.ajax({success: function(xml) { $(xml).find('register').each (function() { alert($(this).find('name').text()) // works fine,shows peter then mary on the next loop of "each" // But if i dont know the tag names (name,age) for each register ? // Something like $(this).nodes().each .... // alert($(this).tagName); // i wanna show "name" & "age",how can i get the tag names inside each register in my xml sample tree? }); }});