2016-12-20 1 views
0

JOOX에서 놀면서 나는 실제로 요소로부터 어떤 값을 얻는 개념에 어려움을 겪고있는 것 같습니다.JOOX : Element의 값을 얻으시오

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> 
    <SOAP-ENV:Header/> 
    <SOAP-ENV:Body> 
     <gwm:getAddressBookListResponse xmlns:gwm="http://schemas.novell.com/2005/01/GroupWise/methods" xmlns:gwt="http://schemas.novell.com/2005/01/GroupWise/types" xmlns:gwe="http://schemas.novell.com/2005/01/GroupWise/events"> 
      <gwm:books> 
       <gwt:book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="gwt:AddressBook"> 
        <gwt:id>[email protected]</gwt:id> 
        <gwt:sid>1</gwt:sid> 
        <gwt:name>Contacts1</gwt:name> 
        <gwt:version>3</gwt:version> 
        <gwt:modified>2016-12-13T07:49:42Z</gwt:modified> 
        <gwt:isPersonal>1</gwt:isPersonal> 
        <gwt:isFrequentContacts>1</gwt:isFrequentContacts> 
       </gwt:book> 
       <gwt:book> 
        <gwt:id>[email protected]</gwt:id> 
        <gwt:name>Contacts2</gwt:name> 
        <gwt:isPersonal>0</gwt:isPersonal> 
        <gwt:isFrequentContacts>0</gwt:isFrequentContacts> 
       </gwt:book> 
       <gwt:book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="gwt:AddressBook"> 
        <gwt:id>[email protected]</gwt:id> 
        <gwt:sid>3</gwt:sid> 
        <gwt:name>Contacts3</gwt:name> 
        <gwt:version>3</gwt:version> 
        <gwt:modified>2016-12-13T07:49:42Z</gwt:modified> 
        <gwt:isPersonal>1</gwt:isPersonal> 
        <gwt:isFrequentContacts>0</gwt:isFrequentContacts> 
       </gwt:book> 
       <gwt:book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="gwt:AddressBook"> 
        <gwt:id>[email protected]</gwt:id> 
        <gwt:sid>5</gwt:sid> 
        <gwt:name>Contacts4</gwt:name> 
        <gwt:version>2</gwt:version> 
        <gwt:modified>2016-12-13T07:49:45Z</gwt:modified> 
        <gwt:description>Bazinga !</gwt:description> 
        <gwt:isPersonal>1</gwt:isPersonal> 
        <gwt:isFrequentContacts>0</gwt:isFrequentContacts> 
       </gwt:book> 
      </gwm:books> 
      <gwm:status> 
       <gwt:code>0</gwt:code> 
      </gwm:status> 
     </gwm:getAddressBookListResponse> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

나는 GWT에 관심이 : ID 요소, 또는 오히려 그 값을

는 다음과 같은 XML을 고려하십시오. 따라서 :

$(document).find("book").find("id").forEach(element -> { 
     element... // now what? 
    }); 

내가 값에만 관심이 있지만은, 요소의 이름과 값 AUT 인쇄로하지 않을 것이다 element.getValue 같은 것은() 및 toString()이 없다. 또한, getNodeValue()가

은 어떻게 (예 : [email protected])

후 오전 요소의 값을 얻기 위해 null을 반환

답변

1

Element 클래스는 Node를 구현 인터페이스이므로 getTextContent()을 사용할 수 있습니다.

XML에서 요소 (태그) 내에 포함 된 텍스트는 노드임을 기억하십시오. 그러므로 은 실제로 "텍스트"와 같은 것을 가지지 않으며, 오직 (아마도) 자손 텍스트 노드 (들) 만 가지고 있습니다.