I'm trying to convert lines in an XML node into an unordered list, however I'm having some difficulty.
Take for example this node :
<test>
Line1
Line2
Line3
</test>
I would like to transform it into this with PHP
<ul>
<li>Line1</li>
<li>Line2</li>
<li>Line3</li>
</ul>
I've tried using DOMDocument and SimpleXML, however neither seem to retain the newlines. When echoed, the node value looks like this :
Line1 Line2 Line3
I've also tried explode
in order to have an array containing each line as an element :
$lines = explode( '\n', $node->nodeValue);
However, it only returns an array with one element, so I can't make an unordered list with it.
Is there a simple way for me to do this?
Thanks.