This repository was archived by the owner on Dec 29, 2020. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathXMLDocument.php
More file actions
72 lines (71 loc) · 2.21 KB
/
Copy pathXMLDocument.php
File metadata and controls
72 lines (71 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* XMLDocument class
*
* PHP Version 5.3.6
*
* @category Class
* @package DOMenhancer
* @author Pierre Rudloff <contact@rudloff.pro>
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
* @link https://code.google.com/p/dom-enhancer/
*/
/**
* Class used to create DOM
*
* PHP Version 5.3.6
*
* @category Class
* @package DOMenhancer
* @author Pierre Rudloff <contact@rudloff.pro>
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
* @link https://code.google.com/p/dom-enhancer/
*/
class DOMenhancer_XMLDocument
{
/**
* Creates a new document with a DOM
*
* @param string $title Content of the title tag
* @param bool $addCSS Add link to a style.css stylesheet in the head tag
*
* @return void
* */
function __construct($title="", $addCSS=false)
{
include_once __DIR__."/DOMElement.php";
include_once __DIR__."/Error.php";
header("Content-type: text/html;charset=utf-8");
$this->DOMimpl=new DOMImplementation();
$doctype=$this->DOMimpl->createDocumentType('html');
$this->DOM=$this->DOMimpl->createDocument(
"http://www.w3.org/1999/xhtml", "html", $doctype
);
$this->DOM->registerNodeClass('DOMElement', 'DOMenhancer_DOMElement');
$this->DOM->html=$this->DOM->documentElement;
$this->DOM->head=$this->DOM->html->head=$this->DOM->createElement("head");
if (!empty($title)) {
$this->DOM->head->addElement("title", $title);
}
$this->DOM->body=$this->DOM->html->body=$this->DOM->createElement("body");
$this->DOM->html->appendChild($this->DOM->html->head);
$this->DOM->html->appendChild($this->DOM->html->body);
if ($addCSS) {
$this->DOM->head->addElement(
"link", null, array(
"rel"=>"stylesheet", "href"=>"style.css", "type"=>"text/css"
)
);
}
$this->DOM->head->addElement("meta", null, array("charset"=>"UTF-8"));
}
/**
* Display the HTML
*
* @return void
* */
function display()
{
echo $this->DOM->saveHTML();
}
}