示例#1
0
 /**
  * @covers ByJG\Util\XmlUtil::removeNode
  */
 public function testRemoveNode()
 {
     $dom = XmlUtil::createXmlDocumentFromStr('<root><subject>Text</subject><a/><b/></root>');
     $node = XmlUtil::selectSingleNode($dom->documentElement, 'subject');
     XmlUtil::removeNode($node);
     $this->assertEquals(self::XMLHEADER . "\n" . '<root>' . '<a/>' . '<b/>' . '</root>' . "\n", $dom->saveXML());
 }
示例#2
0
 /**
  * Remove a node specified by your tag name. You must pass a DOMDocument ($node->ownerDocument);
  *
  * @param DOMDocument $domdocument
  * @param string $tagname
  * @return bool
  */
 public static function removeTagName($domdocument, $tagname)
 {
     $nodeLista = $domdocument->getElementsByTagName($tagname);
     if ($nodeLista->length > 0) {
         $node = $nodeLista->item(0);
         XmlUtil::removeNode($node);
         return true;
     } else {
         return false;
     }
 }