【发布时间】:2018-05-23 19:21:28
【问题描述】:
我有一些我正在尝试用 jQuery 解析的 XML,我如何能够在任何选定的标签中获取值?我试图让“fn”的值显示到控制台中。
var fn = "";
$.ajax({
type: "GET",
url: "xmldata.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('form1').each(function(){
fn = $(this).find('fn').value();
console.log(fn);
});
}
});
console.log(fn);
<?xml version="1.0" encoding="UTF-8"?>
<afData>
<afUnboundData>
<data />
</afUnboundData>
<afBoundData>
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/" timeStamp="2018-05-22T15:17:16Z" uuid="3cd001ed-7c9a-46f7-af5f-3b9e32b11578">
<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
<xfa:data>
<form1>
<fn>John</fn>
<ln>Doe</ln>
<about>My name is John Doe</about>
</form1>
</xfa:data>
</xfa:datasets>
</xdp:xdp>
</afBoundData>
<afSubmissionInfo>
<lastFocusItem>guide[0].guide1[0].guideRootPanel[0].panel1[0]</lastFocusItem>
<computedMetaInfo />
</afSubmissionInfo>
</afData>
【问题讨论】:
标签: javascript jquery html xml aem