note 47907 added to function.dom-domdocument-validate

From: Date: Sun, 05 Dec 2004 05:31:23 +0000
Subject: note 47907 added to function.dom-domdocument-validate
Groups: php.notes 
Request: Send a blank email to php-notes+get-81375@lists.php.net to get a copy of this message
This method throws E_NOTICE errors for any validation errors. If you'd rather store validation errors in an array for gracious handling, you can use the code below. <?php /** * Hold thrown errors statically */ function staticerror($errno, $errstr, $errfile, $errline, $errcontext, $ret = false) { static $errs = array(); if ($ret === true) { return $errs; } $tag = 'DOMDocument::validate(): '; $errs[] = str_replace($tag, '', $errstr); } // Load a document $dom = new DOMDocument; $dom->load('somefile'); // Set up error handling set_error_handler('staticerror'); $old = ini_set('html_errors', false); // Validate $doc->validate(); // Restore error handling ini_set('html_errors', $old); restore_error_handler(); // Get errors $errs = validatewarns(null, null, null, null, null, true); print_r($errs); ?> ---- Manual Page -- http://www.php.net/manual/en/function.dom-domdocument-validate.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47907 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47907&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47907&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47907&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47907&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47907&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47907&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47907&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#81375) next »