<?php
$xml = '<div>
<p>
<a>#</a>
</p>
</div>
';
function xml2array($xml,&$result = '') {
foreach($xml->children() as $name => $xmlchild) {
xml2array($xmlchild,$result);
}
$result = "<ul><li>".$xml->getName().$result."</li></ul>";
}
$result='';
$dd = xml2array(simplexml_load_string($xml),$result);
echo "<pre>";
print_r($result);
выход
<ul>
<li>
div
<ul>
<li>
p
<ul>
<li>
a
</li>
</ul>
</li>
</ul>
</li>
</ul>