2

How can I parse something like this:

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

?

Ilya Vlasov
  • 243
  • 1
  • 2
  • 8
  • 2
    Use @XmlValue - See http://stackoverflow.com/questions/1496052/what-is-the-jaxb-equivalent-of-a-text-node-value – lreeder Oct 12 '13 at 15:09

1 Answers1

1

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();
bdoughan
  • 147,609
  • 23
  • 300
  • 400