我有以下XML,我需要将其转换为java对象.
<tests>
<test-data>
<title>BookTitle</title>
<book>BookName</book>
<count>64018</count>
<test-data>
<title>Book title1</title>
<book>Book Name1</book>
<count>5</count>
</test-data>
<test-data>
<title>Book title2</title>
<book>Book Name3</book>
<count>5</count>
</test-data>
<test-data>
<title>Book title3</title>
<book>Book Name3</book>
<count>4</count>
</test-data>
</test-data>
</tests>
Run Code Online (Sandbox Code Playgroud)
当我使用JAXB转换它时,我不确定我的pojo是什么.
根据我的理解,我创建了以下POJO:
public class Tests {
TestData testData;
public TestData getTestData() {
return testData;
}
public void setTestData(TestData testData) {
this.testData = testData;
}
}
public class TestData {
String title;
String book;
String count;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
} …Run Code Online (Sandbox Code Playgroud) 我把我的代码放在XML验证网站上,它给了我这个错误:
第8行:4根元素后面的文档中的标记必须格式正确.
有问题的<xsl:output method = "html" doctype-system = "about:legacy-compat"/>行是,行.
<?xml version="1.0"?>
<!-- Fig. 15.21: sorting.xsl -->
<xsl:stylesheet version = "1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
<!-- write XML declaration and DOCTYPE DTD information -->
*<xsl:output method = "html" doctype-system = "about:legacy-compat" />*
<!-- match document root -->
<xsl:template match="/"> -<html> <xsl:apply-templates/> </html>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)