I have a function in PHP that retrieves all the directories and files from a given path. This returns me an array like:
array(
"dirname1" => array(
"dirname2" => array(
"dirname3" => array(
"0" => "file1",
"1" => "file2",
"2" => "file3"
),
"0" => "file4",
"1" => "file5",
"2" => "file6",
"dirname4" => array(
"0" => "file7",
"1" => "file8"
)
),
"0" => "file9",
"1" => "file10"
),
"0" => "file11",
"1" => "file12",
"2" => "file13"
);
What I finally need is a multidimensional (don't know if is the exactly word) list with <ul />
and <li />
generated with XSLT 1.0 from a XML file, like:
<ul>
<li class="dirname">
dirname1
<ul>
<li class="dirname">
Dirname2
<ul>
<li class="dirname">
Dirname3
<ul>
<li>file1</li>
<li>file2</li>
<li>file3</li>
</ul>
</li>
<li>file4</li>
<li>file5</li>
<li>file6</li>
<li class="dirname">
dirname4
<ul>
<li>file7</li>
<li>file8</li>
</ul>
</li>
</ul>
</li>
<li>file9</li>
<li>file10</li>
</ul>
</li>
<li>file11</li>
<li>file12</li>
<li>file13</li>
</ul>
And finally, inside every <li />
I need the path in a <a />
, like:
<li class="dirname"><a href="/dirname1">dirname1</a></li>
<li><a href="/dirname1/dirname2/dirname3/file1">file1</a></li>
<li><a href="/dirname1/file9">file9</a></li>
Actually I don't have the XML that I need to convert because I don't know what can be a nice structure for then convert it to XSLT 1.0. I have the paths inside the <a />
. I can do it with PHP if necessary and I can detect in PHP when it is a directory or when not and we can also add something on the XML to detect the class="dirname"
.
I hope I've given sufficient information to understand me.
Thank you in advance!