根据这个txt文件来进行DTD与XML编写
author:王维
title:鹿柴
content:空山不见人,但闻人语声。返景入深林,复照青苔上。
单独使用XML来实现(poem.xml)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE poem [
<!ELEMENT poem (author, title, content)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT content (#PCDATA)>
]>
<poem>
<author>王维</author>
<title>鹿柴</title>
<content>空山不见人,但闻人语声。返景入深林,复照青苔上。</content>
</poem>
使用DTD与XML文件编写(poem2.dtd)
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT poem (author, title, content)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT content (#PCDATA)>
使用DTD与XML文件编写(poem2.xml)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE poem SYSTEM "poem2.dtd">
<poem>
<author>王维</author>
<title>鹿柴</title>
<content>空山不见人,但闻人语声。返景入深林,复照青苔上。</content>
</poem>
使用DTD与XML文件编写(poem3.dtd)
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT poems (poem+)>
<!ELEMENT poem (author, title, content)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT content (#PCDATA)>
使用DTD与XML文件编写(poem3.xml)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE poems SYSTEM "poem3.dtd">
<poems>
<poem>
<author>王维</author>
<title>鹿柴</title>
<content>空山不见人,但闻人语声。返景入深林,复照青苔上。</content>
</poem>
<poem>
<author>王维2</author>
<title>鹿柴</title>
<content>空山不见人,但闻人语声。返景入深林,复照青苔上。</content>
</poem>
</poems>
使用DTD与XML文件编写(poem4.dtd)
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT poems (poem+)>
<!ELEMENT poem (author, title, content)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT content (#PCDATA)>
<!ATTLIST author gender CDATA #FIXED "男">
使用DTD与XML文件编写(poem4.xml)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE poems SYSTEM "poem4.dtd">
<poems>
<poem>
<author gender="男">王维</author>
<title>鹿柴</title>
<content>空山不见人,但闻人语声。返景入深林,复照青苔上。</content>
</poem>
</poems>