nlopess Sun Sep 4 07:41:24 2005 EDT
Modified files:
/phpdoc/en/reference/libxml/functions libxml-get-errors.xml
Log:
commit a nice example improvement that I forgot to commit 1 month ago :)
http://cvs.php.net/diff.php/phpdoc/en/reference/libxml/functions/libxml-get-errors.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/libxml/functions/libxml-get-errors.xml
diff -u phpdoc/en/reference/libxml/functions/libxml-get-errors.xml:1.2
phpdoc/en/reference/libxml/functions/libxml-get-errors.xml:1.3
--- phpdoc/en/reference/libxml/functions/libxml-get-errors.xml:1.2 Tue Feb
15 12:20:43 2005
+++ phpdoc/en/reference/libxml/functions/libxml-get-errors.xml Sun Sep 4
07:41:23 2005
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<refentry id="function.libxml-get-errors">
<refnamediv>
<refname>libxml_get_errors</refname>
@@ -50,29 +50,33 @@
XML;
$doc = simplexml_load_string($xmlstr);
+$xml = explode("\n", $xmlstr);
if (!$doc) {
$errors = libxml_get_errors();
foreach ($errors as $error) {
- echo display_xml_error($error);
+ echo display_xml_error($error, $xml);
}
libxml_clear_errors();
}
-function display_xml_error($error) {
+function display_xml_error($error, $xml)
+{
+ $return = $xml[$error->line - 1] . "\n";
+ $return .= str_repeat('-', $error->column) . "^\n";
switch ($error->level) {
case LIBXML_ERR_WARNING:
- $return = "Warning $error->code: ";
+ $return .= "Warning $error->code: ";
break;
case LIBXML_ERR_ERROR:
- $return = "Error $error->code: ";
+ $return .= "Error $error->code: ";
break;
case LIBXML_ERR_FATAL:
- $return = "Fatal Error $error->code: ";
+ $return .= "Fatal Error $error->code: ";
break;
}
@@ -84,7 +88,7 @@
$return .= "\n File: $error->file";
}
- return "$return\n";
+ return "$return\n\n--------------------------------------------\n\n";
}
?>
@@ -93,9 +97,13 @@
&example.outputs;
<screen>
<![CDATA[
+ <titles>PHP: Behind the Parser</title>
+^
Fatal Error 76: Opening and ending tag mismatch: titles line 4 and title
Line: 4
Column: 0
+
+--------------------------------------------
]]>
</screen>
</example>