@@ -221,7 +221,14 @@ public function load($markup, $contentType = null, $newDocumentID = null)
221221 }
222222 if ($ loaded ) {
223223 // $this->document->formatOutput = true;
224+ $ this ->document ->formatOutput = false ;
224225 $ this ->document ->preserveWhiteSpace = true ;
226+
227+ $ this ->document ->validateOnParse =false ;
228+ $ this ->document ->strictErrorChecking =false ;
229+ $ this ->document ->recover =false ;
230+
231+
225232 $ this ->xpath = new DOMXPath ($ this ->document );
226233 $ this ->afterMarkupLoad ();
227234
@@ -294,11 +301,21 @@ protected function documentCreate($charset, $version = '1.0')
294301 if (!$ version ) {
295302 $ version = '1.0 ' ;
296303 }
304+
305+ libxml_use_internal_errors (true );
306+
297307 $ this ->document = new DOMDocument ($ version , $ charset );
298308 $ this ->charset = $ this ->document ->encoding ;
299309 // $this->document->encoding = $charset;
300- $ this ->document ->formatOutput = true ;
310+ // $this->document->formatOutput = true;
311+ $ this ->document ->formatOutput = false ;
312+ // $this->document->standalone = true;
301313 $ this ->document ->preserveWhiteSpace = true ;
314+
315+
316+ $ this ->document ->validateOnParse =false ;
317+ $ this ->document ->strictErrorChecking =false ;
318+ $ this ->document ->recover =false ;
302319 }
303320
304321 protected function loadMarkupHTML ($ markup , $ requestedCharset = null )
@@ -378,7 +395,15 @@ protected function loadMarkupHTML($markup, $requestedCharset = null)
378395 ? $this->document->loadHTML($markup)
379396 : @$this->document->loadHTML($markup); */
380397
381- $ return = @$ this ->document ->loadHTML ($ markup );
398+ // $return = @$this->document->loadHTML($markup);
399+ $ return = @$ this ->document ->loadHTML ($ markup ,
400+ LIBXML_SCHEMA_CREATE |
401+ LIBXML_HTML_NOIMPLIED |
402+ LIBXML_HTML_NODEFDTD |
403+ LIBXML_NOERROR |
404+ LIBXML_NONET |
405+ LIBXML_NOWARNING
406+ );
382407
383408 if ($ return ) {
384409 $ this ->root = $ this ->document ;
@@ -763,6 +788,10 @@ private function documentFragmentLoadMarkup($fragment, $charset, $markup = null)
763788 .'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" '
764789 .'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> '
765790 .'<fake xmlns="http://www.w3.org/1999/xhtml"> ' .$ markup .'</fake> ' );
791+
792+ /* $fragment->loadMarkupXML('<?xml version="1.0" encoding="'.$charset.'"?>'*/
793+ // . phpQuery::$defaultDoctype.''
794+ // .'<fake xmlns="http://www.w3.org/1999/xhtml">'.$markup.'</fake>');
766795 $ fragment ->root = $ fragment ->document ->firstChild ->nextSibling ;
767796 } else {
768797 $ fragment ->loadMarkupXML ('<?xml version="1.0" encoding=" ' .$ charset .'"?><fake> ' .$ markup .'</fake> ' );
@@ -5079,8 +5108,10 @@ abstract class phpQuery
50795108 *
50805109 * @var unknown_type
50815110 */
5082- public static $ defaultDoctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
5111+ public static $ defaultDoctype_old = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
50835112"http://www.w3.org/TR/html4/loose.dtd"> ' ;
5113+
5114+ public static $ defaultDoctype = '<!doctype html> ' ;
50845115 public static $ defaultCharset = 'UTF-8 ' ;
50855116
50865117 /**
0 commit comments