我低于 XML
<Root>
<field/>
<field/>
<field>
<label>
Have you invested before
</label>
<value>
No
</value>
<label>
Are you looking to Invest in the next 6 months
</label>
<value>
Maybe
</value>
</field>
<field>
<label>
What Investments are you interested in
</label>
<value>
Carbon Credits, Green Investments
</value>
</field>
<field>
<label>
How much are you looking to invest
</label>
<value>
£250,000+
</value>
</field>
从这里我需要HTML
像下面这样渲染它。
Have you invested before: No
Are you looking to invest in the next 6 months: Maybe
What investments are you interested in: Carbon Credits, Green Investments
How much are you looking to invest: £250,000+
目前它的输出是:
:
:
Have you invested beforeAre you looking to Invest in the next 6 months: YesMaybe
What Investments are you interested in: Carbon Credits, Green Investments
How much are you looking to invest: £250,000+
我在下面使用,jquery
但它没有产生我期望的输出。
$(data).find('field').each(function (index, element) {
debugger;
//if (field.find('label').length > 0) {
var field = $(element)
if (field.find('label').length > 1) {
var confirmationNumbers = $(field).find("label").map(function () {
//debugger;
list.append('<dt>' + label + ': </dt>').append('<dd>' + value + '</dd>');
return $(this).text();
});
//var label = field.find('label').text()
//var value = field.find('value').text()
//list.append('<dt>' + label + ': </dt>').append('<dd>' + value + '</dd>');
}
else {
var label = field.find('label').text()
var value = field.find('value').text()
list.append('<dt>' + label + ': </dt>').append('<dd>' + value + '</dd>');
}
//}
});
我做错了什么..