I have to try taking some simple UL tag produced in PHP (Joomla 1.5) and wrap each anchor tag's text quite happy with a SPAN tag. The incoming HTML appears like this:

<ul>
  <li>
      <a href="#">Home</a>
    </li>
    <li>
      <a href="#">Watch UNC-TV</a>
    </li>
    <li>
      <a href="#" >Contact</a>
    </li>
</ul>

The output must seem like this:

<ul id="top-nav" class="flatList">
  <li class="selected">
      <a href="#"><span class="embed embed-top-nav">Home</span>
        <p >news, highlights</p></a>
    </li>
    <li>
      <a href="#"><span class="embed embed-top-nav">Watch UNC-TV</span>
        <p>schedule, local programs</p></a>
    </li>
    <li id="nav-last">
      <a href="#"><span class="embed embed-top-nav">Contact</span>
        <p>feedback, connect, share</p></a>
    </li>
</ul>

Also note the course put into the active LI tag ("selected") and also the class put into the final one out of their email list ("nav-last"). This really is in Joomla 1.5, where I am overriding the mod_mainmenu module utilized by the Primary Menu. The code uses the SimpleXML library to read the HTML within the modMainMenuXMLCallback(&$node, $args):

<?php
defined('_JEXEC') or die('Restricted access');

if ( ! defined('fancyMenuPatch') ) 
{
  function fancyMenuPatch($result,$tag){
    // Replace UL tag with ours. 
    // Replace LI tag with ours.

    // Add to the start of the UL tag.
    $begin_ul = "<ul id=\"top-nav\" class=\"flatList\">";
    $begin_li = "<li>"; //not sure what to do with this.

    // do the replacement
    $result = str_replace("<ul>",$begin_ul, $result);
    $result = str_replace("<li>", $begin_li, $result);

    return $result;
  }

  define('fancyMenuPatch', true);
}

if ( ! defined('modMainMenuXMLCallbackDefined') )
{
function modMainMenuXMLCallback(&$node, $args)
{
  $user = &JFactory::getUser();
  $menu = &JSite::getMenu();
  $active   = $menu->getActive();
  $path = isset($active) ? array_reverse($active->tree) : null;

  if (($args['end']) && ($node->attributes('level') >= $args['end']))
  {
    $children = $node->children();
    foreach ($node->children() as $child)
    {
      if ($child->name() == 'ul') {
        $node->removeChild($child);
      }
    }
  }

  if ($node->name() == 'ul') {
    foreach ($node->children() as $child)
    {
      if ($child->attributes('access') > $user->get('aid', 0)) {
        $node->removeChild($child);
      }
    }
  }

  if (($node->name() == 'li') && isset($node->ul)) {
    $node->addAttribute('class', 'parent');
  }

  if (isset($path) && (in_array($node->attributes('id'), $path) || in_array($node->attributes('rel'), $path)))
  {
    if ($node->attributes('class')) {
      $node->addAttribute('class', $node->attributes('class').' active');
    } else {
      $node->addAttribute('class', 'active');
    }
  }
  else
  {
    if (isset($args['children']) && !$args['children'])
    {
      $children = $node->children();
      foreach ($node->children() as $child)
      {
        if ($child->name() == 'ul') {
          $node->removeChild($child);
        }
      }
    }
  }

  if (($node->name() == 'li') && ($id = $node->attributes('id'))) {
    if ($node->attributes('class')) {
      $node->addAttribute('class', $node->attributes('class').' item'.$id);
    } else {
      $node->addAttribute('class', 'item'.$id);
    }
  }

  if (isset($path) && $node->attributes('id') == $path[0]) {
    $node->addAttribute('id', 'current');
  } else {
    $node->removeAttribute('id');
  }
  $node->removeAttribute('rel');
  $node->removeAttribute('level');
  $node->removeAttribute('access');
}
  define('modMainMenuXMLCallbackDefined', true);
}

ob_start();

modMainMenuHelper::render($params, 'modMyMainMenuXMLCallback');
$menu_html = ob_get_contents();
ob_end_clean(); 

if($params->get('menutype')=="primarynav"){
  $tag = $params->get('tag_id');
  }
//output the menu!
echo fancyMenuPatch($menu_html,$tag);
?>

Thanks.