这是XML文件:NameKeyValueNameAnotherNameKeyValue我想得到名字。但只有第一个SubCat的名称。和属性键值。问题是SubCat存在两次。我试过这个:$(xml).find('SubCat').each(function(){varname=$(this).find("Name").text();alert(name);}但这显示了第一个和第二个SubCat的名称。我正在寻找这样的东西。rootElement(Category).selectallchildren(SubCat).NameforthefirstSubCatNamerootElement