Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added a workaround for quirk with DOMDocument->loadXML

, adding an optional encoding argument to the domtemplate constructor.
(should we be using loadHTML?)
  • Loading branch information...
commit 8e556fbe9bac8cff7de033846cbc2a43d6283a75 1 parent 8824de5
@fyra authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/domtemplate.php
View
7 lib/domtemplate.php
@@ -12,10 +12,13 @@
class DOMTemplate extends DOMTemplateNode {
private $DOMDocument;
- public function __construct ($filepath, $NS = '', $NS_URI = '') {
+ public function __construct ($filepath, $NS = '', $NS_URI = '', $document_encoding="utf-8") {
//load the template file to work with. this must be valid XML (but not XHTML)
$this->DOMDocument = new DOMDocument ();
$this->DOMDocument->loadXML (
+ //add XML declaration to avoid mangling non-ascii characters
+ // see http://www.php.net/manual/en/domdocument.loadxml.php#94291
+ "<?xml version=\"1.0\" encoding=\"$document_encoding\"?>"
//replace HTML entities (e.g. "&copy;") with real unicode characters to prevent invalid XML
self::html_entity_decode (file_get_contents ($filepath)), LIBXML_COMPACT | LIBXML_NONET
) or trigger_error (
@@ -264,4 +267,4 @@ public function next () {
}
}
-?>
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.