1-0-1,this is a test
3-1-1,this is a test
4-3-1,this is a test
5-3-1,this is a test
2-0-2,this is a test
上面是BBS主题列表的一个例子。一般来说,假如不是使用Oracle(Oracle 有一条查询语句可以自动生成家族树,请查阅Select ... start with ... connect by ...语句),那么如何实现上例的列表是一件费事的工作(相信许多程序员都写过)。
如果我们改用XML来实现,那么结果会怎么样呢?
现在我们使用"Select * from bbs"从数据库中查询贴子,并以XML格式返回(如果你是用ADO,那么可以用其RecordSet.Save ... adPersistXML直接生成,当然如果你不喜欢ADO生成的格式,可用程序生成,如本例):
表B:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="b.xsl"?>
<bbs>
<post sid="4" pid="3" aid="1">
<title>4-3-1,this is a test</title>
<content>slddfjslajfsdljf</content>
</post>
<post sid="5" pid="3" aid="1">
<title>5-3-1,this is a test</title>
<content>slddfjslajfsdljf</content>
</post>
<post sid="3" pid="1" aid="1">
<title>3-1-1,this is a test</title>
<content>slddfjslajfsdljf</content>
</post>
<post sid="1" pid="0" aid="1">
<title>1-0-1,this is a test</title>
<content>slddfjslajfsdljf</content>
</post>
<post sid="2" pid="0" aid="2">
<title>2-0-2,this is a test</title>
<content>slddfjslajfsdljf</content>
</post>
</bbs>