Best alternative to ASP.Net's web.sitemap in PHP
<p>In ASP.Net I usually drive my primary navigation using a standard <code>web.sitemap</code> file such as the following:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" &gt;
    &lt;siteMapNode url="~/index.html" title="My Awesome Site"&gt;
        &lt;siteMapNode url="~/About/index.html" title="About"&gt;
            &lt;siteMapNode url="~/About/Board.html" title="Board"/&gt;
            &lt;siteMapNode url="~/About/Vision.html" title="Vision"/&gt;
            &lt;siteMapNode url="~/About/Mission.html" title="Mission"/&gt;
            &lt;siteMapNode url="~/About/Support.html" title="Support"/&gt;
            &lt;siteMapNode url="~/About/Locations.html" title="Locations"/&gt;
            &lt;siteMapNode url="~/About/Funding-Sources.html" title="Funding Sources"/&gt;
            &lt;siteMapNode url="~/About/Volunteer.html" title="Volunteer"/&gt;
            &lt;siteMapNode url="~/About/Staff.html" title="Staff"/&gt;
        &lt;/siteMapNode&gt;
        &lt;siteMapNode url="~/Parents/index.html" title="Parents"&gt;
            &lt;siteMapNode url="~/Parents/Child-Development.html" title="Child Development"/&gt;
            &lt;siteMapNode url="~/Parents/Referrals.html" title="Referrals"/&gt;
        &lt;/siteMapNode&gt;
        &lt;siteMapNode url="~/Resources/index.html" title="Resources"&gt;
            &lt;siteMapNode url="~/Resources/Resource-Library.html" title="Resource Library"/&gt;
            &lt;siteMapNode url="~/Resources/Links.html" title="Links"/&gt;
        &lt;/siteMapNode&gt;
    &lt;/siteMapNode&gt;
&lt;/siteMap&gt;
</code></pre>

<p>Then I usually create a user control for the navigation where I can use <code>SiteMap.CurrentNode</code> and/or <code>SiteMap.CurrentNode.IsDescendantOf</code> to mark the current page as "selected" or whatever. I'm looking for something similar for PHP. In ASP classic we would pretty much have to use an include and a bunch of <code>if</code> statements which works but once you get a couple of levels deep you end up with a bunch of code. I could probably create variables at the top of each page designating which "section", "subsection" and "page" we're on but I'd like to avoid that if possible.</p>

<p>I found <a href="http://www.webdesign.org/web-programming/php/php-navigation.10746.html" rel="nofollow">this link</a> which bounces things through the querystring but that's not an option.</p>

<p>If anyone's not familiar with the <code>web.sitemap</code> file I can explain it in more detail if needed.</p>

<p><strong>EDIT - Comments for @BrandonS</strong></p>

<p>The core of what I'm looking for is to be able to define a single file that represents the pages of my site. ASP.Net uses an XML file which is convenient for catching some potential errors but isn't required. Ideally I'd actually like to use exact same file format used by ASP.Net so that I can share code but still not absolutely required.</p>

<p>In ASP.Net, using the sitemap above I would have a user control (basically a glorified include file) that outputs the <code>&lt;title&gt;</code> tag on every page. On the <strong>Home</strong> page it would output just <code>My Awesome Site</code>, on the <strong>About</strong> L2 page it would output <code>My Awesome Site - About</code> and on the <strong>Board</strong> L3 page it would output <code>My Awesome Site - About - Board</code>. The same idea might be used for breadcrumbs on subpages. (Quick aside, for all of my sites pages exist only once so there's no chance of a page having two parents.)</p>

<p>In ASP.Net on every page request a SiteMap object gets automatically created. (Actually I think its lazy-loaded meaning it actually doesn't get created unless you try accessing but that happens transparently.) So at any given moment I can use a <code>SiteMap.CurrentNode</code> object on any page that exists in the sitemap file. (If the page doesn't exist in the sitemap file <code>null</code> is returned.) From that I can ask for the <code>SiteMap.CurrentNode.ParentNode</code> or I can walk the <code>SiteMap.CurrentNode.ChildNodes</code>. I can also get the <code>SiteMap.RootNode</code> which represents the root of the sitemap file. From that I can walk the <code>SiteMap.RootNode.ChildNodes</code> knowing that these direct children represent the Level 2 pages of my site. I can then walk these children individually knowing that each "grandchild" represents an L3 and so on.</p>

<p>So using the above recursion I could define my site's primary navigation by walking the root node's children and if I've got dropdown menus in my nav then I can walk the sub-children. While walking the children or grandchildren I can set classes based on if the <code>SiteMap.CurrentNode</code> equals or is descended from the child or grandchild. Below is an example in VB.Net of how I use the sitemap for building an L2 navigation:</p>

<pre><code>    ''//An array that we append potential CSS class names to such as "first" or "active"
    Dim Classes As List(Of String)

    ''//A StringBuild is just an efficient way to work with Strings
    ''//if you are not familiar with it just now that Append() is basically "&amp;=" and AppenLine() is basically "&amp;= ...\n"
    Dim Buf As New StringBuilder()
    Buf.AppendLine("     &lt;ul&gt;")

    ''//Walk the root child nodes, the N variable will be the current ChildNode of the SiteMap.RootNote
    For Each N As SiteMapNode In SiteMap.RootNode.ChildNodes

        ''//For the first and last child we want to add extra classes in case we need to adjust borders, padding, etc
        Classes = New List(Of String)
        If N.PreviousSibling Is Nothing Then
            Classes.Add("first")
        ElseIf N.NextSibling Is Nothing Then
            Classes.Add("last")
        End If

        ''//See if the page being requested is the current child or if the current page is descended from it so that we can mark it as active
        If SiteMap.CurrentNode IsNot Nothing Then
            If SiteMap.CurrentNode.Equals(N) OrElse SiteMap.CurrentNode.IsDescendantOf(N) Then
                Classes.Add("active")
            End If
        End If

        ''//This code below is just for outputting the &lt;li class="..."&gt;&lt;a href="..."&gt;...&lt;/a&gt;&lt;/li&gt; code

        ''//Write the opening list tag
        Buf.Append("      &lt;li")
        ''//If the above code created any CSS classes append the class attribute and the space-delimited list of classes
        If Classes.Count &gt; 0 Then
            Buf.Append(" class=""" &amp; Join(Classes.ToArray(), " ") &amp; """")
        End If
        ''//Close the list tag
        Buf.Append("&gt;")

        ''//Append the hyperlink. The "N" object is the current child of the SiteMap.RootNode.ChildNodes
        ''//All SiteMapNode objects have a Url property and a Title property which is defined in the XML file
        Buf.AppendFormat("&lt;a href=""{0}""&gt;{1}&lt;/a&gt;&lt;/li&gt;", N.Url.Replace("/index.html", "/"), HttpUtility.HtmlEncode(N.Title))

        ''//Append a blank line, I like to keep my code formatted nicely
        Buf.AppendLine()
    Next

    ''//Append the closing list tag
    Buf.AppendLine("     &lt;/ul&gt;")
</code></pre>

<p><strong>Additional note</strong></p>

<p>Some people might think that this is overkill but this is all built into .Net, that's why I'm asking if something exists for PHP. I could roll my own but obviously I'd like to avoid it if possible.</p>
