2

我怎样才能解析这样的东西:

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

?

4

1 回答 1

1

你可以有:

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

    @XmlValue
    private int value:

}

或者你可以这样做:

Integer response = unmarshaller.unmarshal(xml, Integer.class).getValue();
于 2013-10-12T19:56:59.133 回答