Forum Discussion
vijaydi
13 years agoContributor
Hi McDonald,
The below code for capturing values under similiar XPath in an array works well. In the case below, the value to capture are in attributes.
However, the same when trying to capture the values in a node, ends ups with the follwing exception (groovy.lang.MissingMethodException: No signature of method: org.apache.xmlbeans.impl.store.Xobj$ElementXobj.getNodeValue() is applicable for argument types: (java.lang.String) values: [thf:code])
The below code is what I am using to capture the node value. Please help.
The part of the reposne file that I am trying to capture.
<thf:faults>
<thf:fault>
<thf:code>033</thf:code>
<thf:faultString>PPSR Unavailable</thf:faultString>
</thf:fault>
<thf:fault>
<thf:code>031</thf:code>
<thf:faultString>ATO Unavailable</thf:faultString>
</thf:fault>
</thf:faults>
</cth:companyTradingHistoryReport>
</cth:companyTradingHistoryResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The below code for capturing values under similiar XPath in an array works well. In the case below, the value to capture are in attributes.
def indicators = []
holder.getDomNodes('//ns5:search-result').each {
def attrs = []
attrs << it.getAttribute('match-indicator') << it.getAttribute('search-name') << it.getAttribute('match-score')
indicators << attrs
}
However, the same when trying to capture the values in a node, ends ups with the follwing exception (groovy.lang.MissingMethodException: No signature of method: org.apache.xmlbeans.impl.store.Xobj$ElementXobj.getNodeValue() is applicable for argument types: (java.lang.String) values: [thf:code])
The below code is what I am using to capture the node value. Please help.
def indicators = []
holder.getDomNodes('//cth:companyTradingHistoryResponse[1]/cth:companyTradingHistoryReport[1]/thf:faults[1]/thf:fault').each {
indicators << it.getNodeValue('thf:code') + "_" + it.getNodeValue('thf:faultString')
}
The part of the reposne file that I am trying to capture.
<thf:faults>
<thf:fault>
<thf:code>033</thf:code>
<thf:faultString>PPSR Unavailable</thf:faultString>
</thf:fault>
<thf:fault>
<thf:code>031</thf:code>
<thf:faultString>ATO Unavailable</thf:faultString>
</thf:fault>
</thf:faults>
</cth:companyTradingHistoryReport>
</cth:companyTradingHistoryResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>