Java 解析SOAP主体时如何从NodeList对象中提取属性值
因此,我有一条xml soap消息,看起来是这样的:Java 解析SOAP主体时如何从NodeList对象中提取属性值,java,xml,soap,xml-parsing,Java,Xml,Soap,Xml Parsing,因此,我有一条xml soap消息,看起来是这样的: ... <FinalValueFee1 currencyID="USD">8.0</FinalValueFee> <FinalValueFee2 currencyID="ILS">6.0</FinalValueFee> <FinalValueFee3 currencyID="EUR">1.0</FinalValueFee> <FinalValueFee4 curre
...
<FinalValueFee1 currencyID="USD">8.0</FinalValueFee>
<FinalValueFee2 currencyID="ILS">6.0</FinalValueFee>
<FinalValueFee3 currencyID="EUR">1.0</FinalValueFee>
<FinalValueFee4 currencyID="USD">4.0</FinalValueFee>
...
如何为它们中的每一个选择
currencyID
?m\u soapBody.getElementsByTagName(“FinalValueFee1”)。项(0)
返回一个节点
对象。可在此处查看该对象下可用的各种方法:
通过查看文档,以下任何一项都应该得到您所寻求的值:
node.getAttributes().getNamedItem("currencyID").getNodeValue();
node.getAttributes().getNamedItem("currencyID").getTextContent();
node.getAttributes().getNamedItem("currencyID").getNodeValue();
node.getAttributes().getNamedItem("currencyID").getTextContent();