Пример #1
0
 /**
  * Gets a path to a node via SPL Stack implementation
  *
  * Pass in the child node and will recurse up the XML tree to print out
  * the path in the tree to that node
  *
  * <config>
  *   <path>
  *     <to>
  *       <node>
  *         Node Value
  *       </node>
  *     </to>
  *   </path>
  * </config>
  *
  * If you pass in the "node" object, this will print out
  * config/path/to/node/
  *
  * @param SimpleXmlElement $element Child element to find path to
  *
  * @return string
  * @access public
  */
 public function getPath(SimpleXmlElement $element)
 {
     $this->_iterator->push($element->getName() . '/');
     if (!$element->getSafeParent()) {
         return $this->_iterator->pop();
     }
     return $this->getPath($element->getParent()) . $this->_iterator->pop();
 }
Пример #2
0
 /**
  * Gets a path to a node via array implementation
  *
  * Pass in the child node and will recurse up the XML tree to print out
  * the path in the tree to that node
  *
  * <config>
  *   <path>
  *     <to>
  *       <node>
  *         Node Value
  *       </node>
  *     </to>
  *   </path>
  * </config>
  *
  * If you pass in the "node" object, this will print out
  * config/path/to/node/
  *
  * @param SimpleXmlElement $element Child element to find path to
  *
  * @return string
  * @access public
  */
 public function getPath(SimpleXmlElement $element)
 {
     $this->_iterator[] = $element->getName() . '/';
     if (!$element->getSafeParent()) {
         return array_pop($this->_iterator);
     }
     return $this->getPath($element->getParent()) . array_pop($this->_iterator);
 }