Example #1
0
 public function testTrait()
 {
     $document = new DomDocument();
     $html = $document->createElement('html');
     $document->appendChild($html);
     $html->addElement('head');
     $body = $document->createElement('body');
     $html->appendChild($body);
     $foobar = $body->addElement('p')->setAttribute('title', 'foobar');
     $foo = $document->createElement('p')->setAttribute('title', 'foo');
     $body->insertBefore($foo, $foobar);
     $body->insertAfter($document->createElement('p')->setAttribute('title', 'bar'), $foo);
     $this->assertXmlStringEqualsXmlFile(__DIR__ . '/DomDocument/trait.xml', (string) $document);
 }
Example #2
0
 /**
  * @param string $tagName Tag name.
  * @param string $nodeValue Node value (ignored).
  * @return \Blar\Dom\DomElement
  */
 public function createElement($tagName, $nodeValue = NULL)
 {
     $namespace = $this->resolveNamespace($tagName);
     if ($namespace) {
         return parent::createElementNS($namespace, $tagName);
     }
     return parent::createElement($tagName);
 }