使用下面的 XML,我想用 jQuery 将数据解析成一个表。不幸的是,我在获得用户学位(而不是审阅者学位)时遇到了一些麻烦。我还没有考虑获取名字或姓氏(我认为它会相似)。
XML:
<data>
<status>true</status>
<candidates>
<user>
<username>user1</username>
<degree>BS</degree>
<email>test1@test.com</email>
<firstname>John</firstname>
<lastname>Candidate</lastname>
<reviewedby></reviewedby>
<notreviewedby>
<reviewer>
<degree>BSc</degree>
<firstname>Eric</firstname>
<lastname>Reviewer</lastname>
<username>e_reviewer</username>
</reviewer>
</notreviewedby>
</user>
<user>
<username>user2</username>
<degree>BS</degree>
<email>test2@test.com</email>
<firstname>Francis</firstname>
<lastname>CandidateAswell</lastname>
<reviewedby></reviewedby>
<notreviewedby>
<reviewer>
<degree>BS</degree>
<firstname>Fred</firstname>
<lastname>Reviews</lastname>
<username>f_reviewer</username>
</reviewer>
</notreviewedby>
</user>
</candidates>
我不完全确定为什么:
$(response).find('user').each(function(){
var degree = $("> degree", this).text();
alert(degree);
});
不工作...
感谢您的任何指示。