什么是demo4j??
demo4j是一种框架,主要作用是用来解析XML文档的开放源代码.首先我们创建一个web项目,在pom.xml文件中导入依赖文件:
<!-- https://mvnrepository.com/artifact/dom4j/dom4j -->
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
然后创建一个com.yjh.pojo对象:
public class Book {
int id;
String author;
String title;
----Getter and setter---方法
----toString------------方法
}
接着在资源文件reources中创建Book.xml配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book id="1" class="com.yjh.pojo.Book">
<title>Harry Potter</title>
<author>J K. Rowling</author>
</book>
<book id="2" class