在玩 JOOX 时,我似乎对从元素中实际获取一些值的概念感到困惑。
考虑以下 XML:
<?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>584FB626.hbo.abp_poa1.104.16E3363.1.1.1@53</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>GroupWiseSystemAddressBook@52</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>584FB626.hbo.haporo_poa1.104.16E3363.1.3.1@53</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>584FB629.hbo.haporo_poa1.104.16E3363.1.5.1@53</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 元素或它们的值感兴趣。因此:
$(document).find("book").find("id").forEach(element -> {
element... // now what?
});
没有 element.getValue() 之类的东西,而 toString() 不会做,因为它会打印 aut 元素名称和值,尽管我只对值感兴趣。此外,getNodeValue() 返回 null
如何获取我所追求的元素的值(例如584FB629.hbo.haporo_poa1.104.16E3363.1.5.1@53)