comparison class.template.php @ 9:d06e9d5ff344

Affichage correctement indenté (d'après PHP) du fichier XML de sortie.
author Franck Deroche <webmaster@defr.org>
date Sun, 21 Oct 2007 14:30:54 +0200
parents 0b796d56c767
children 04b1d6bca316
comparison
equal deleted inserted replaced
8:0b796d56c767 9:d06e9d5ff344
6 const NS = 'http://defr.net/2007/template'; 6 const NS = 'http://defr.net/2007/template';
7 7
8 function __construct($fileName, $shouldValidate = false) { 8 function __construct($fileName, $shouldValidate = false) {
9 $this->xmlDocument = new DOMDocument(); 9 $this->xmlDocument = new DOMDocument();
10 $this->xmlDocument->validateOnParse = $shouldValidate; 10 $this->xmlDocument->validateOnParse = $shouldValidate;
11 $this->xmlDocument->preserveWhiteSpace = false;
11 $this->xmlDocument->loadXML(file_get_contents($fileName)); 12 $this->xmlDocument->loadXML(file_get_contents($fileName));
12 $this->xmlXPath = new DOMXPath($this->xmlDocument); 13 $this->xmlXPath = new DOMXPath($this->xmlDocument);
13 $this->xmlXPath->registerNamespace('_t', Template::NS); 14 $this->xmlXPath->registerNamespace('_t', Template::NS);
14 } 15 }
15 16
149 } 150 }
150 } 151 }
151 152
152 function __toString() { 153 function __toString() {
153 $this->clean(); 154 $this->clean();
154 $this->xmlDocument->saveXML(); 155 $this->xmlDocument->formatOutput = true;
155 return $this->xmlDocument->saveXML(); 156 return $this->xmlDocument->saveXML();
156 } 157 }
157 } 158 }