Say I have:
<ul>
<li id="x">
<a href="x">x</a>
</li>
<li id="y">
<a href="y">y</a>
<ul>
<li id="z">
<a href="z">z</a>
</li>
</ul>
</li>
</ul>
I want to add a class value to all the list items that are the parents of z. So, I want to modify y but not x.
Obviously, I can parse this into some kind of associative array and then recurse backwards. Any ideas how I can do it with just text processing (string replacing, regular expression, etc)?
Thanks!