Cohesion
Cohesion

Reputation: 243

Root element without children. JAXB

How can I parse something like this:

<?xml version="1.0">
<response>1</response>

?

Upvotes: 2

Views: 294

Answers (1)

bdoughan
bdoughan

Reputation: 149057

You could have:

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Response {

    @XmlValue
    private int value:

}

Alternatively you could do:

Integer response = unmarshaller.unmarshal(xml, Integer.class).getValue();

Upvotes: 1

Related Questions