XML 문서에서 jQuery를 사용하여 "product"요소의 "name"속성에 대한 고유 속성 값을 검색하여 중복을 삭제하려고합니다. How to use jQuery to select XML nodes with unique text content?jquery에서 xml doc의 고유 속성 검색
어떤 도움이 근을 이해할 수있을 것이다 : 여기이 토론에 제안
그러나, 나는, 독특한() 함수 또는 배열을 만드는 어떤 성공을 없었어요. 미리 감사드립니다.
내 XML :
<products>
<product name="first"></product>
<product name="second"></product>
<product name="first"></product>
<product name="first"></product>
</products>
내 작동하지 않는 코드 : 내 머리에 오는
function getName() {
$.ajax({
type: "GET",
url: xmlFile.xml,
dataType: "xml",
success: function(xml) {
$(xml).find('product').each(function(){
var name = $(this).attr('name');
var productArray = new Array();
if(jQuery.inArray(name, productArray) == -1){
$('<p></p>').html(name).appendTo('body');
productArray.push(name);
}
});
}
});
}
와우 이제 작동합니다! 내 잘못. 대단히 빠르고 쉽습니다. – bobighorus