Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 没有子元素的根元素。JAXB_Java_Xml_Jaxb - Fatal编程技术网

Java 没有子元素的根元素。JAXB

Java 没有子元素的根元素。JAXB,java,xml,jaxb,Java,Xml,Jaxb,我如何解析这样的内容: <?xml version="1.0"> <response>1</response> 1. ?您可以: @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class Response { @XmlValue private int value: } 或者,您可以: Integer response = unmarshaller.unma

我如何解析这样的内容:

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

1.

您可以:

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

    @XmlValue
    private int value:

}
或者,您可以:

Integer response = unmarshaller.unmarshal(xml, Integer.class).getValue();
使用@XmlValue-请参阅