开发者

Most efficient way to store list structure in XML

开发者 https://www.devze.com 2022-12-25 20:05 出处:网络
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 st

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.

&l开发者_如何学运维t;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?

Thank you. :)


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)


Are you sure about using XML as a database? See: When would I use XML instead of 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.“

0

精彩评论

暂无评论...
验证码 换一张
取 消