Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Most efficient way to store list structure in XML

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.

<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. :)

like image 949
Mike Avatar asked Nov 05 '22 14:11

Mike


1 Answers

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)

like image 128
Marc Gravell Avatar answered Nov 15 '22 13:11

Marc Gravell