Esempio n. 1
0
 /**
  * @param string $qualifiedName Qualified name of the document element.
  * @param string $publicId Public id.
  * @param string $systemId System id.
  * @return self
  */
 public function addDocType($qualifiedName, $publicId, $systemId)
 {
     $implementation = new DomImplementation();
     $type = $implementation->createDocumentType($qualifiedName, $publicId, $systemId);
     $this->appendChild($type);
     return $this;
 }
Esempio n. 2
0
 public function testSimple()
 {
     $implementation = new DomImplementation();
     $type = $implementation->createDocumentType('html', '-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd');
     $document = $implementation->createDocument('http://www.w3.org/1999/xhtml', 'html', $type);
     $html = $document->documentElement;
     $head = $html->addElement('head');
     $head->addElement('title')->addText('Hello');
     $head->addElement('meta')->setAttributes(array('name' => 'Keywords', 'content' => 'php, dom'));
     $body = $html->addElement('body');
     $body->addElement('p')->addText('Hello World');
     $this->assertEquals('Blar\\Dom\\DomDocument', get_class($document));
     $this->assertXmlStringEqualsXmlFile(__DIR__ . '/DomImplementation/simple.xml', (string) $document);
     # var_dump($document->validate());
     # die();
 }
Esempio n. 3
0
 public function testAppendDoctypeAndValidateWithReload()
 {
     $implementation = new DomImplementation();
     $type = $implementation->createDocumentType('html', '-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd');
     $document = new DomDocument();
     $document->appendChild($type);
     $html = $document->addElementNS('http://www.w3.org/1999/xhtml', 'html');
     $head = $html->addElement('head');
     $head->addElement('title');
     $html->addElement('body');
     $document->reload();
     $this->assertTrue($document->validate());
 }