/** * test loading xml data from file */ public function testFileLoading() { $testFile = 'src/Test/data/source.xml'; $this->assertFileExists($testFile, 'test file don\'t exists'); $xml = new Xml(); $xml->loadXmlFile($testFile); $this->assertFalse($xml->hasErrors()); $root = $xml->documentElement; $this->assertEquals('lorem ipsum', $root->getElementsByTagName('sub')->item(0)->nodeValue); }
/** * append data to node * * @param string $addCdata * @param Xml $xml * @param string|integer $key * @param string $value * @return DOMElement */ protected function _appendDataToNode($addCdata, Xml $xml, $key, $value) { if ($addCdata) { $cdata = $xml->createCDATASection($value); $element = $xml->createElement($this->_integerToStringKey($key)); $element->appendChild($cdata); } else { $element = $xml->createElement($this->_integerToStringKey($key), $value); } return $element; }