public function testXpathShouldReturnInstancesOfQuiteSimpleXMLElement() { $el = QuiteSimpleXMLElement::make('<doc xmlns="http://www.loc.gov/zing/srw/"><hello>first</hello><hello>second</hello></doc>', ['s' => 'http://www.loc.gov/zing/srw/']); $this->assertContainsOnlyInstancesOf('Danmichaelo\\QuiteSimpleXMLElement\\QuiteSimpleXMLElement', $el->xpath('hello')); }
/** * Replaces the current node. Thanks to @hakre * <http://stackoverflow.com/questions/17661167/how-to-replace-xml-node-with-simplexmlelement-php>. */ public function replace(QuiteSimpleXMLElement $element) { $oldNode = $this->asDOMElement(); $newNode = $oldNode->ownerDocument->importNode($element->asDOMElement(), true); $oldNode->parentNode->replaceChild($newNode, $oldNode); }