PHP xml retain tags in childNode

m23hay

New Member
I fetched this string on to the database:\[code\]$str = "<ol><li><span style="color:rgb(255,153,0);"><b style="color:rgb(255,153,0);">Maximum</b></span> authority</li><li>Innovative response</li><li>Freedom<br></li></ol>";\[/code\]I wanted to split the string into an array, having the values inside \[code\]<li>\[/code\] to be the value and coming up with something like this:\[code\][0] => <span style="color:rgb(255,153,0);"><b style="color:rgb(255,153,0);">Maximum</b></span> authority[1] => Innovative response[2] => Freedom<br>\[/code\]However, I only come up with this solution:\[code\]$xml = new DOMDocument();$xml->loadHTML($str);foreach($xml->getElementsByTagName('li') as $li) $final_list[] = $li->nodeValue;// Results[0] => Maximum authority[1] => Innovative response[2] => Freedom\[/code\]It strips the HTML tags inside \[code\]<li>\[/code\] which is not my expected result. Any ideas to improve this?
 
Back
Top