Quantcast
Channel: GUJ - Tópicos com a tag java
Viewing all articles
Browse latest Browse all 17410

[RESOLVIDO] XStream

$
0
0

@rodrigobraz escreveu:

Bom dia.

Estou usando a biblioteca XStream 1.4.4 para recuperar Xml e transformar em Objetos.

Estou com a seguinte situação que não consigo resolver:

Tenho uma tag (docZip) que o valor dela é uma String Base64, porém, essa tag tem atributos.

A estrutura é a seguinte:

<retDistDFeInt>
     .......
    <loteDistDFeInt>
        <docZip schema="......." NSU=".....">valor em string base 64 ...............</docZip>
    </loteDistDFeInt>
</retDistDFeInt>

Estou tentando configurar da seguinte forma:

XStream xstream = new XStream();
xstream.alias("retDistDFeInt", RetornoDistribuicaoDFeInteresse.class);
xstream.alias("loteDistDFeInt", LoteDistribuicaoDFeInteresse.class);
xstream.useAttributeFor(RetornoDistribuicaoDFeInteresse.class, "xmlns");
xstream.useAttributeFor(RetornoDistribuicaoDFeInteresse.class, "versao");
xstream.addImplicitCollection( LoteDistribuicaoDFeInteresse.class, "listDocZip");
xstream.alias("docZip", DocZip.class);
xstream.useAttributeFor(DocZip.class, "schema");
xstream.useAttributeFor(DocZip.class, "NSU");
            
return (RetornoDistribuicaoDFeInteresse) xstream.fromXML( _xml );

Eu criei uma classe DocZip para poder pegar os atributos, mas não sei como fazer para pegar o valor da String Base64.

Alguém tem uma idéia de como fazer?!

Segue as classes:

public class DocZip implements Serializable{
    
    private String NSU;
    private String schema;
....



public class LoteDistribuicaoDFeInteresse implements Serializable {

    private List<DocZip> listDocZip;
....


public class RetornoDistribuicaoDFeInteresse implements Serializable {
    
    private String versao;
    private String xmlns;
...
...
    private LoteDistribuicaoDFeInteresse loteDistDFeInt;

Obrigado!

Mensagens: 4

Participantes: 2

Ler tópico completo


Viewing all articles
Browse latest Browse all 17410

Latest Images

Trending Articles

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>