Javascript 用jQuery读取XML
Javascript 用jQuery读取XML,javascript,jquery,xml,Javascript,Jquery,Xml,State=“MO”liccat=“Prof0008”type=“Professional Engineer”includeInProposal=“Y”expiration=“12/31/2016”/> 我还没有对它进行测试,但看起来您需要更改这一行: Here's the XML: 对此 return 'hello' + $(this).children('State').text() + " " ; 用$(xml)替换$(xml).用$(xml)替换find('employees'),
State=“MO”liccat=“Prof0008”type=“Professional Engineer”includeInProposal=“Y”expiration=“12/31/2016”/>
我还没有对它进行测试,但看起来您需要更改这一行:
Here's the XML:
对此
return 'hello' + $(this).children('State').text() + " " ;
用
$(xml)替换$(xml).用$(xml)替换find('employees')
,$(this).children('State').text()
(this).attr('State')属性不是children如果答案有帮助,请投票/标记为答案:)
return 'hello' + $(this).attr('State') + " " ;
$(xml).find('employee').each(function(){
var emp = $(this).attr("lastName"); /* read the root */
var images = $('licenses license',this).map(function() {
return 'hello ' + $(this).attr('State') + " " ;
}).get().join('');
console.log(images);
});