java - org.apache.axiom.om.impl.llom.OMTextImpl cannot be cast to org.apache.axiom.om.OMElement -


i'm trying following.

omelement soapenvelope = new staxombuilder(soapenvelopxmlfilepath).getdocumentelement(); omelement firstelement = soapenvelope.getfirstelement().getfirstelement(); 

then iterate through child elements of firstelement this.

iterator<omelement> items = firstelement.getchildren(); while (items.hasnext()) {     omelement element = items.next();     // ....do processing here... } 

but when try execute following class cast exception occurs.

java.lang.classcastexception: org.apache.axiom.om.impl.llom.omtextimpl cannot cast org.apache.axiom.om.omelement  

the error occurs when items.next() assigned element omelement object.

any idea why i'm getting exception? can't figure out mismatch.

these contents of sample xml file.

    <?xml version="1.0" encoding="utf-8"?>     <soapenv:envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">         <soapenv:body>             <ns:monitor xmlns:ns="http://try.example.com">                 <ns:hosts>                     <ns:host name="node1">                         <ns:metric name="metric1" value="1123"/>                         <ns:metric name="metric3" value="456"/>                         <ns:metric name="metric2" value="789"/>                     </ns:host>                     <ns:host name="node2">                         <ns:metric name="metric1" value="147"/>                         <ns:metric name="metric3" value="258"/>                         <ns:metric name="metric2" value="369"/>                     </ns:host>                 </ns:hosts>                 <ns:hosts>                     <ns:host name="node3">                         <ns:metric name="metric1" value="236"/>                         <ns:metric name="metric3" value="159"/>                         <ns:metric name="metric2" value="478"/>                     </ns:host>                 </ns:hosts>             </ns:monitor>         </soapenv:body> 

thanks.

use getchildelements instead of getchildren.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -