2014-01-08 1 views
0

안녕하세요 이름을 지정하고돌아 XML 노드는

내 질문은 XML 정보를 파싱/AJAX 반환 관련이 사전에 감사합니다.

성공적인 요청을 반환하지만 모든 XML 노드 ngPropertyName을 반환합니다. 내가 성취하고자하는 것은 특정 카테고리 (Physical, Medial, Family, ect)에 대한 모든 ngPropertyName xml 노드를 반환하는 것입니다. 전체

$(xml).find('ngCategory').each(function(){ 
      $(xml).find('ngPropertyName').each(function(){ 
       var profilePhysicalAt = $(this).text(); 
       result += "<li>" + profilePhysicalAt + "</li>"; 
      }) 
    }); 

    <ngCategory name="PHYSICAL"> 
    <ngProperty> 
     <ngPropertyID>1287</ngPropertyID> 
     <ngPropertyName>Height</ngPropertyName> 
     <ListItems> 
     <Item id="725">3'0</Item> 
     <Item id="726">3'1</Item> 
     </ListItems> 
    </ngProperty> 
<ngProperty> 
    <ngPropertyID>1288</ngPropertyID> 
    <ngPropertyName>Weight</ngPropertyName> 
    <ListItems> 
    <Item id="797">25</Item> 
    <Item id="798">26</Item> 
    <Item id="799">27</Item> 
     </ListItems> 
    </ngProperty> 

    </ngCategory> 

    <ngCategory name="Medical"> 
    <ngProperty> 
     <ngPropertyID>1287</ngPropertyID> 
     <ngPropertyName>Height</ngPropertyName> 
     <ListItems> 
     <Item id="725">3'0</Item> 
     <Item id="726">3'1</Item> 
     </ListItems> 
    </ngProperty> 

, 그 특정 범주에 대한 모든 ngPropertyName를 반환하고 싶습니다. 현재 모든 내 cateogries에서 모든 ngPropertyName을 가져옵니다.

감사합니다.

답변

0

이렇게하려면 xml DOM을 사용해야합니다. http://www.w3schools.com/dom/dom_nodes_get.asp

JQuery와 API를 사용하여 압축을 해제하지 마십시오 :

이 링크를 따르십시오.

+0

시도했습니다. Didnt work 경고 ("물리적 노드 가져 오기"); \t if (window.XMLHttpRequest) \t { \t \t xhttp = new XMLHttpRequest(); \t 다른} \t // IE 5/6 \t { \t \t xhttp = 새로운 ActiveXObject ("에서는 Microsoft.XMLHTTP"); \t} \t xhttp.open ("GET", "URL", false); \t xhttp.send(); \t xmlDoc = xhttp.responseXML; \t \t var a = xmlDoc.getElementsByTagName ("ngdataset"); \t var b = a.getElementsByTagName ("ngCategory") [0]; \t var c = b.getElementsByTagName ("ngProperty") [0]; \t var x = c.getElementsByTagName ("ngPropertyID") [0]; \t var y = x.childNodes [0]; \t var txt = y.nodeValue; \t \t 경고 (txt); – user2626307