0

I'm trying to use the simpleframework converter to convert this XML :

<?xml version="1.0" encoding="UTF-8" ?>
<dvds generator="$Id: dvd.tpl 855 2008-08-04 15:53:24Z glapierre $"></dvds>

To those classes :

@Root
public class SearchResult {
    @Attribute(name = "generator")
    private String generator;
    @ElementList(entry = "dvd", inline = true, required = false, empty = true)
    private List<DVDResult> dvds;

    public SearchResult() {}

    public List<DVDResult> getDVDs() {
        return dvds;
    }

    public String getGenerator() {
        return generator;
    }
}

@Root
public class DVDResult { 
    // Some @Element with getters 
}

When the list is not empty there is no problem but in this particular case I get a org.simpleframework.xml.stream.NodeException: Document has no root element and I really don't know why.

I thought that it was on my @ElementList so I had entry and empty but no changes. I also removed name from @Roots.

Does somebody have an answer to that?

Thomas T.
  • 59
  • 1
  • 6

1 Answers1

0

Problem solved. It was my parsing which was over-complicated. I was using the SimpleXML factory, changed it to :

Serializer serializer = new Persister();
SearchResult result = serializer.read(SearchResult.class, myXMLString);
Thomas T.
  • 59
  • 1
  • 6