在XML中存储列表结构的最有效方法

时间:2022-11-22 16:56:14

Starting a new project and was planning on storing all of my web content in XML. I do not have access to a database so this seemed like the next best thing. One thing I'm struggling with is how to structure the XML for links (which will later be transformed using XSLT). It needs to be fairly flexible as well. Below is what I started with, but I'm starting to question it.

启动一个新项目,并计划将所有Web内容存储在XML中。我无法访问数据库,所以这似乎是下一个最好的事情。我正在努力的一件事是如何为链接构建XML(稍后将使用XSLT进行转换)。它也需要相当灵活。以下是我的开始,但我开始质疑它。

<links>
    <link>
        <url>http://google.com</url>
        <description>Google</description>
    <link>
    <link>
        <url>http://yahoo.com</url>
        <description>Yahoo</description>
        <links>
            <url>http://yahoo.com/search</url>
            <description>Search</description>
        </link>
    <link>
</links>

That should get transformed into

那应该变成了

Google Yahoo Search

谷歌雅虎搜索

Perhaps something like this might work better.

也许这样的事情可能会更好。

<links>
    <link href="http://google.com">Google</link>
    <link href="http://yahoo.com">Yahoo
        <link href="http://yahoo.com/search">Search</link>
    </link>
</links>

Does anyone perhaps have a link that talks about structuring web content properly in XML?

有没有人可能有一个链接,谈论在XML中正确构建Web内容?

Thank you. :)

谢谢。 :)

2 个解决方案

#1


2  

I would be tempted to use something like:

我很想使用类似的东西:

<links>
  <link url="http://google.com" text="Google"/>
  <link url="http://yahoo.com" text="Yahoo">
    <links>
      <link url="http://yahoo.com/search" text="Search"/>
    </links>
  </link>
</links>

(although the inner <links> is optional and could be removed so you had links/link/link)

(虽然内部 是可选的,可以删除所以你有链接/链接/链接)

#2


0  

Are you sure about using XML as a database? See: When would I use XML instead of SQL?

您确定将XML用作数据库吗?请参阅:何时使用XML而不是SQL?

“XML is not a database. It was never meant to be a database. It is never going to be a database. Relational databases are proven technology with more than 20 years of implementation experience. They are solid, stable, useful products. They are not going away. XML is a very useful technology for moving data between different databases or between databases and other programs. However, it is not itself a database. Don't use it like one.“

“XML不是数据库。它从来就不是一个数据库。它永远不会成为一个数据库。关系数据库是经过验证的技术,具有20多年的实施经验。它们是坚固,稳定,实用的产品。它们不会消失。 XML是一种非常有用的技术,用于在不同数据库之间或数据库与其他程序之间移动数据。但是,它本身并不是一个数据库。不要像那样使用它。“

#1


2  

I would be tempted to use something like:

我很想使用类似的东西:

<links>
  <link url="http://google.com" text="Google"/>
  <link url="http://yahoo.com" text="Yahoo">
    <links>
      <link url="http://yahoo.com/search" text="Search"/>
    </links>
  </link>
</links>

(although the inner <links> is optional and could be removed so you had links/link/link)

(虽然内部 是可选的,可以删除所以你有链接/链接/链接)

#2


0  

Are you sure about using XML as a database? See: When would I use XML instead of SQL?

您确定将XML用作数据库吗?请参阅:何时使用XML而不是SQL?

“XML is not a database. It was never meant to be a database. It is never going to be a database. Relational databases are proven technology with more than 20 years of implementation experience. They are solid, stable, useful products. They are not going away. XML is a very useful technology for moving data between different databases or between databases and other programs. However, it is not itself a database. Don't use it like one.“

“XML不是数据库。它从来就不是一个数据库。它永远不会成为一个数据库。关系数据库是经过验证的技术,具有20多年的实施经验。它们是坚固,稳定,实用的产品。它们不会消失。 XML是一种非常有用的技术,用于在不同数据库之间或数据库与其他程序之间移动数据。但是,它本身并不是一个数据库。不要像那样使用它。“