0
jqueryフィルタ関数を使用してXMLを解析しようとしていますが、問題が発生しています。 私のXMLは次のようになります。XMLデータを取得する - Jquery - Filter
<root>
<data name="0121C395-AFCE-49C8-A163-55E24325D691" xml:space="preserve">
<value>Report an incident</value>
</data>
<data name="0121C395-AFCE-49C8-A163-55E24325D691_descr" xml:space="preserve">
<value>In this service it's possible to report incidents.</value>
</data>
<data name="0121C395-AFCE-49C8-A163-55E24325D691_short" xml:space="preserve">
<value>Report Incident</value>
</data>
</root>
そして、私のjqueryのは次のようになります。
$(document).ready(function(){
$.ajax({
type: "GET",
url: "http://localhost/servicemarket/ReachOut/Services.xml",
dataType: "xml",
success: function(xml){
var dataVal = $(xml).find('data').filter(function(){
return $('data', this).attr('name') == '0121C395-AFCE-49C8-A163-55E24325D691';
});
dataVal.each(function(index, data){
console.log($(data).find('value').text());
});
},
error: function() {
alert("An error occurred while processing XML file.");
}
});
});
私の目標は、入力データの属性に基づいて、ノードの値を取得することです。 すべてのご協力をいただきありがとうございます。 :) ありがとうございました!