How can I parse an xml that has a vector inside another vector?

1

I'm having a question about how I can parse an xml that the server is sending me.     I can get the data up to the Cobranca tag after this tag has another array that I can not get. Here's the one part of xml:

<return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:DebitosPendentes[19]">
                <item xsi:type="tns:DebitosPendentes">
                    <Vencimento xsi:type="xsd:string">2016-05-07</Vencimento>
                    <ValorAtualizado xsi:type="xsd:decimal">102.00</ValorAtualizado>
                    <Valor xsi:type="xsd:decimal">100.00</Valor>
                    <Sequencia xsi:type="xsd:string">182</Sequencia>
                    <NroBanco xsi:type="xsd:int">39</NroBanco>
                    <BcoCobr xsi:type="xsd:int">237</BcoCobr>
                    <Cobranca xsi:type="xsd:string">S</Cobranca>
                    <Itens xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:ListaItens[1]">
                        <item xsi:type="tns:ListaItens">
                            <Descricao xsi:type="xsd:string">COBR ws</Descricao>
                            <ValorItem xsi:type="xsd:decimal">100.00</ValorItem>
                        </item>
                    </Itens>
                </item>

Follow the code:

 public  void buscaDebitosPendentes(int codigoCliente){


        SoapObject request = new SoapObject("urn:RouterBoxMobile","BuscarDebitosPendentes");

        SoapObject chaveIntegracao = new SoapObject("urn:RouterBoxMobile","BuscarDebitosPendentes");
        chaveIntegracao.addProperty("ChaveIntegracao",chaveDeIntegracao);
        request.addProperty("Autenticacao",chaveIntegracao);

        SoapObject codigo = new SoapObject("urn:RouterBoxMobile","BuscarDebitosPendentes");

        codigo.addProperty("CodigoCliente",codigoCliente);

        request.addProperty("DadosDebitosPendentes",codigo);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(request);
        envelope.implicitTypes=true;

        HttpTransportSE httpTransportSE = new HttpTransportSE(URL_WEBSERVICE);

         httpTransportSE.debug=true;

        try {
            httpTransportSE.call("",envelope);

            Log.d("Request",httpTransportSE.requestDump.toString());
            Log.d("Response",httpTransportSE.responseDump.toString());


           @SuppressWarnings("unchecked")
            Vector<Object> vector = (Vector<Object>) envelope.getResponse();

            Log.d("Response in SOAP",vector.toString());

            for (int i=0; i< vector.size();i++){
                SoapObject object = (SoapObject) vector.get(i);
                if (object!=null){
                    Log.d("Vencimento",object.getProperty("Vencimento").toString());
                    Log.d("Sequencia",object.getProperty("Sequencia").toString());
                    Log.d("Descricao",object.getProperty("Descricao").toString());


                }
            }

        } catch (IOException e) {
            e.printStackTrace();
        } catch (XmlPullParserException e) {
            e.printStackTrace();
        }

    }
    
asked by anonymous 11.11.2016 / 14:51

1 answer

0

I was able to solve the problem of the following, I get the position where the xml array comes from and I went to a vector. Follow the code:

Vector<SoapObject> vector = (Vector<SoapObject>) envelope.getResponse();


           Log.d("Response in SOAP",vector.toString());

            for (int i=0; i< vector.size();i++){
                SoapObject object = (SoapObject) vector.get(i);

               if (object!=null){
                  Log.d("Vencimento", object.getProperty(0).toString());
                   Log.d("ValorAtualizado", object.getProperty(1).toString());
                   Log.d("Valor", object.getProperty(2).toString());
                   Log.d("Sequencia", object.getProperty(3).toString());
                   Log.d("NroBanco", object.getProperty(4).toString());
                   Log.d("BcoCobr", object.getProperty(5).toString());
                   Log.d("Cobranca", object.getProperty(6).toString());

                   Vector<Object> itens= (Vector<Object>) object.getProperty(7);

                   for (int j=0; j<itens.size();j++){
                         SoapObject item =(SoapObject) itens.get(j);
                       Log.d("Descricao", item.getProperty("Descricao").toString());
                       Log.d("ValorItem", item.getProperty("ValorItem").toString());

                   }



                }

            }
    
16.11.2016 / 17:15