I would like to convert the list structure to html:
<ul> <li>Section 1</li> <li>Section 2 <ul> <li>Section 2.1</li> <li>Section 2.2</li> </ul> </li> <li>Section 3</li> </ul>
In XML, like this:
<sections> <section> <caption>Section 1</caption> <level>0</level> </section> <section> <caption>Section 2</caption> <level>0</level> </section> <section> <caption>Section 2.1</caption> <level>1</level> </section> <section> <caption>Section 2.2</caption> <level>1</level> </section> <section> <caption>Section 3</caption> <level>0</level> </section> </sections>
I tried using PHP SimpleXML for reading in html, but it seems to have a problem when it encounters the <ul> tag inside the <li> .
Interestingly, someone can kindly suggest what is the easiest way to do this in PHP?
Many thanks to all of you.
source share