假设我有一个JSON结构,描述了如下所示的引号集合(这只是显示第一个引号)。
如何在第一个引号中获得名为“更多腿部空间”的福利说明。
<Quotes>
<Quote>
<Price>1.50</Price>
<Benefits>
<Benefit>
<Name>Free Meals</Name>
<Description>Get Free Meals on every journey</Description>
<Benefit>
<Benefit>
<Name>More legroom</Name>
<Description>Get more leg room on every journey</Description>
<Benefit>
<Benefit>
<Name>Free Drinks</Name>
<Description>Get Free Drinks on every journey</Description>
<Benefit>
</Benefits>
</Quotes>
<Quote>
答案 0 :(得分:0)
for (var i = 0; i < quotes[0].Benefits.length; i++) {
if (jQuery.trim(quotes[0].Benefits[i].Name == "More legroom")) {
benefitDescription = quotes[0].Benefits[i].Description
}
}