• 您的位置我爱Aspx >> XML/XLST >> 使用XML实现BBS(主题列表篇)
  • 使用XML实现BBS(主题列表篇)

  • 作者:aspxer  来源:网络  日期:2007-4-24 22:11:43  关键字:xml
  • 表A:

    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 ... startwith ... connect by ...语句),那么如何实现上例的列表是一件费事的工作(相信许多程序员都写过)。

    如果我们改用XML来实现,那么结果会怎么样呢?

    现在我们使用"Select * from bbs"从数据库中查询贴子,并以XML格式返回(如果你是用ADO,那么可以用其RecordSet.Save ... adPersistXML直接生成,当然如果你不喜欢ADO生成的格式,可用程序生成,如本例):

    表B:

    <?xml version="1.0"?>

    <?xml-stylesheet type="text/xsl" href="http://www.web521.com/XML/541468/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>

    我对这篇文章有话说?
  • 广告位招租,广告代号:content_468_15
  • 上一篇:把数据转换成XML格式的好处
    下一篇:HTML中的XML数据岛记录编辑与添加