public function xmlToCMSNavItem(ModelObject $CMSNavItem, SimpleXMLExtended $xml)
 {
     if (($id = $xml->attribute('id')) !== null) {
         $CMSNavItem->CMSNavItemID = intval($id);
     }
     if (($id = $xml->attribute('slug')) !== null) {
         $CMSNavItem->Slug = strval($id);
     }
     if (($id = $xml->attribute('pluginid')) !== null) {
         $CMSNavItem->PluginID = strval($id);
     }
     if (($id = $xml->attribute('uri')) !== null) {
         $CMSNavItem->URI = strval($id);
     }
     if (($id = $xml->attribute('create_add_menu')) !== null) {
         $CMSNavItem->DoAddLinksFor = strval($id);
     }
     if (($id = $xml->attribute('enabled')) !== null) {
         $CMSNavItem->Enabled = StringUtils::strToBool($id);
     } else {
         $CMSNavItem->Enabled = true;
     }
     foreach (array('label', 'sort_order', 'permissions', 'parent_slug') as $key) {
         $camel = StringUtils::camelize($key);
         $CMSNavItem->{$camel} = trim($xml->attribute($key));
     }
     if ($CMSNavItem->Slug == '') {
         $CMSNavItem->Slug = SlugUtils::createSlug($CMSNavItem->Label);
     }
     if (empty($CMSNavItem->SortOrder)) {
         $CMSNavItem->SortOrder = PHP_INT_MAX;
     }
     $children = array();
     foreach ($xml as $childNode) {
         if ($childNode->getName() == 'item') {
             $child = $this->xmlToCMSNavItem(new CMSNavItem(), $childNode);
             $child->ParentSlug = $CMSNavItem->Slug;
             $children[] = $child;
             $sort_array[] = $child->SortOrder;
             $sort_array2[] = $child->Slug;
         }
     }
     if (!empty($children)) {
         array_multisort($sort_array, SORT_ASC, $sort_array2, SORT_ASC, $children);
     }
     $CMSNavItem->Children = $children;
     //        if($xml->creation_date)
     //            $CMSNavItem->CreationDate = $this->DateFactory->newStorageDate(strval($xml->creation_date));
     //        if($xml->modified_date)
     //            $CMSNavItem->ModifiedDate = $this->DateFactory->newStorageDate(strval($xml->modified_date));
     return $CMSNavItem;
 }