public function cmsNavItemToXML(ModelObject $CMSNavItem)
 {
     $xml = new SimpleXMLExtended('<item/>');
     $xml->addAttribute('id', $CMSNavItem->CMSNavItemID);
     $xml->addAttribute('pluginid', $CMSNavItem->PluginID);
     $xml->addAttribute('uri', $CMSNavItem->URI);
     foreach (array('slug', 'label', 'sort_order', 'permissions') as $key) {
         $camel = StringUtils::camelize($key);
         if (!empty($CMSNavItem->{$camel})) {
             $xml->addAttribute($key, $CMSNavItem->{$camel});
         }
     }
     $xml->addAttribute('enabled', $CMSNavItem->isEnabled() ? 'true' : 'false');
     if (!empty($CMSNavItem->DoAddLinksFor)) {
         $xml->addAttribute('create_add_menu', $CMSNavItem->DoAddLinksFor);
     }
     //        if($CMSNavItem->hasModifiedDate())
     //            $xml->addChild('modified_date', $this->DateFactory->toStorageDate($CMSNavItem->ModifiedDate)->toMySQLDate());
     //        if($CMSNavItem->hasCreationDate())
     //            $xml->addChild('creation_date', $this->DateFactory->toStorageDate($CMSNavItem->CreationDate)->toMySQLDate());
     $sort_array = array();
     $children = $CMSNavItem->getChildren();
     if (!empty($children)) {
         foreach ($children as $child) {
             $sort_array[] = $child->SortOrder;
             $sort_array2[] = $child->Slug;
         }
         array_multisort($sort_array, SORT_ASC, $sort_array2, SORT_ASC, $children);
         foreach ($children as $child) {
             $xml->addXMLElement($this->cmsNavItemToXML($child));
         }
     }
     return $xml;
 }