コード例 #1
0
ファイル: Map.php プロジェクト: fwk/xml
 /**
  * Returns childrens values
  *
  * @param Path             $path Current Path
  * @param SimpleXMLElement $node Current SimpleXML node
  *
  * @return array
  */
 protected function getChildrens(Path $path, SimpleXMLElement $node)
 {
     $current = array();
     foreach ($path->getChildrens() as $child) {
         $key = $child->getKey();
         $csxml = $node->xpath($child->getXpath());
         $val = $child->getDefault();
         if (is_array($csxml) && count($csxml)) {
             $val = $this->pathToValue($csxml, $child);
         }
         $current[$key] = $val;
         if ($val === null && $child->isLoop()) {
             $current[$key] = array();
         }
     }
     return $current;
 }