function &getElementByPath($path) { $ref =& parent::getElementByPath($path); if (!$ref) { $classname = get_class($this); $ref = new $classname('empty'); } return $ref; }
/** * Testing getElementByPath(). * * @param string The path ('/' as separator) to the XML node name * @param JSimpleXMLElement The index into the XMLTree ($child) of the sought node. * * @return void * @dataProvider casesPath */ public function testGetElementByPath($path, $expected) { $this->buildXMLTree(); $this->assertThat( $this->object->getElementByPath($path), $this->equalTo($this->child[$expected]) ); }
/** * Get an element in the document by / separated path * * @param string $path The / separated path to the element * @return object JSimpleXMLElement */ function &getElementByPath($path) { return parent::getElementByPath(str_replace(':', '_0x3a', $path)); }