Hey all!
I got an HTML string that I need to parse (to be used in Flash), by wrapping nested UL tags by a span with incremented left-margin
value based on nesting level.
Before:
<ul>
<li>Item one</li>
<li>Item two:
<ul>
<li>One</li>
<li>Two
<ul>
<li>One</li>
<li>Two</li>
</ul>
</li>
</ul>
</li>
<li>Item three
<ul>
<li>One</li>
<li>Two</li>
</ul>
</li>
<li>Item four</li>
</ul>
After:
<span style="left-margin:0px">
<ul>
<li>Item one</li>
<li>Item two:
<span style="left-margin:30px">
<ul>
<li>One</li>
<li>Two
<span style="left-margin:60px">
<ul>
<li>One</li>
<li>Two</li>
</ul>
</span>
</li>
</ul>
</span>
</li>
<li>Item three
<span style="left-margin:30px">
<ul>
<li>One</li>
<li>Two</li>
</ul>
</span>
</li>
<li>Item four</li>
</ul>
</span>
Note the incremented value: 0, 30, 60...
I did a (nasty) ActionScript solution, but I think there must be some elegant way to do it.