<?php
function crea_option($dom,$niv,$texto,$refer='')
{
     global $xuli0,$xuli1,$xuli2,$xuli3,$xuli4,$xuli5;
     $xlist=${'xuli'.(int)($niv-1)}->appendChild($dom->createElement("li"));
     $ahref=$xlist->appendChild($dom->createElement("a",$texto));
     if(!empty($refer))
     {$ahref->setAttribute("href",$refer);}
     else
     {${'xuli'.(int)($niv)}=$xlist->appendChild($dom->createElement("ul"));}
}


$dom=new DomDocument();
     $dom->encoding = 'utf-8';
     $dom->xmlVersion = '1.0';
     $dom->xmlStandalone = true;
     $dom->formatOutput = true;

$xuli0=$dom->appendChild($dom->createElement("ul"));   
     $xuli0->setAttribute("menu","main");
     $xuli0->setAttribute("class","slimmenu");

crea_option($dom,1,'Registros');
     crea_option($dom,2,'Documentos');
          crea_option($dom,3,'Docum 1','http:youtube.com');
          crea_option($dom,3,'Docum 1','http:jw.org');
     crea_option($dom,2,'Ventas');
          crea_option($dom,3,'Fact','http:netflix.com');
          crea_option($dom,3,'N/C','http:eluniverso.com');

crea_option($dom,1,'Consultas');
     crea_option($dom,2,'Ventas');
          crea_option($dom,3,'X Cliente','http:youtube.com');
          crea_option($dom,3,'X Producto','http:jw.org');
     crea_option($dom,2,'Inventarios');
          crea_option($dom,3,'Ingresos','http:netflix.com');
          crea_option($dom,3,'Egresos','http:eluniverso.com');


echo $dom->saveXML();
?>
