2005-02-14 18:01:02 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2005-02-15 17:20:43 +00:00
|
|
|
<!-- $Revision: 1.2 $ -->
|
2005-02-14 18:01:02 +00:00
|
|
|
<refentry id="function.libxml-get-errors">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>libxml_get_errors</refname>
|
|
|
|
<refpurpose>
|
|
|
|
Retrieve array of errors
|
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
|
|
|
<methodsynopsis>
|
2005-02-15 17:20:43 +00:00
|
|
|
<type>array</type><methodname>libxml_get_errors</methodname>
|
2005-02-14 18:01:02 +00:00
|
|
|
<void/>
|
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
2005-02-15 17:20:43 +00:00
|
|
|
Retrieve array of errors.
|
2005-02-14 18:01:02 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
2005-02-15 17:20:43 +00:00
|
|
|
|
2005-02-14 18:01:02 +00:00
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
|
|
|
<para>
|
2005-02-15 17:20:43 +00:00
|
|
|
Returns an array with <type>LibXMLError</type> objects if there are any
|
|
|
|
errors in the buffer, or an empty array otherwise.
|
2005-02-14 18:01:02 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
|
|
|
<para>
|
|
|
|
<example>
|
2005-02-15 17:20:43 +00:00
|
|
|
<title>A <function>libxml_get_errors</function> example</title>
|
2005-02-14 18:01:02 +00:00
|
|
|
<para>
|
2005-02-15 17:20:43 +00:00
|
|
|
This example demonstrates how to build a simple libxml error handler.
|
2005-02-14 18:01:02 +00:00
|
|
|
</para>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
2005-02-15 17:20:43 +00:00
|
|
|
|
|
|
|
libxml_use_internal_errors(true);
|
|
|
|
|
|
|
|
$xmlstr = <<< XML
|
|
|
|
<?xml version='1.0' standalone='yes'?>
|
|
|
|
<movies>
|
|
|
|
<movie>
|
|
|
|
<titles>PHP: Behind the Parser</title>
|
|
|
|
</movie>
|
|
|
|
</movies>
|
|
|
|
XML;
|
|
|
|
|
|
|
|
$doc = simplexml_load_string($xmlstr);
|
|
|
|
|
|
|
|
if (!$doc) {
|
|
|
|
$errors = libxml_get_errors();
|
|
|
|
|
|
|
|
foreach ($errors as $error) {
|
|
|
|
echo display_xml_error($error);
|
|
|
|
}
|
|
|
|
|
|
|
|
libxml_clear_errors();
|
2005-02-14 18:01:02 +00:00
|
|
|
}
|
2005-02-15 17:20:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
function display_xml_error($error) {
|
|
|
|
|
|
|
|
switch ($error->level) {
|
|
|
|
case LIBXML_ERR_WARNING:
|
|
|
|
$return = "Warning $error->code: ";
|
|
|
|
break;
|
|
|
|
case LIBXML_ERR_ERROR:
|
|
|
|
$return = "Error $error->code: ";
|
|
|
|
break;
|
|
|
|
case LIBXML_ERR_FATAL:
|
|
|
|
$return = "Fatal Error $error->code: ";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$return .= trim($error->message) .
|
|
|
|
"\n Line: $error->line" .
|
|
|
|
"\n Column: $error->column";
|
|
|
|
|
|
|
|
if ($error->file) {
|
|
|
|
$return .= "\n File: $error->file";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "$return\n";
|
|
|
|
}
|
|
|
|
|
2005-02-14 18:01:02 +00:00
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
&example.outputs;
|
|
|
|
<screen>
|
|
|
|
<![CDATA[
|
2005-02-15 17:20:43 +00:00
|
|
|
Fatal Error 76: Opening and ending tag mismatch: titles line 4 and title
|
|
|
|
Line: 4
|
|
|
|
Column: 0
|
2005-02-14 18:01:02 +00:00
|
|
|
]]>
|
|
|
|
</screen>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
|
|
|
<para>
|
|
|
|
<simplelist>
|
2005-02-15 17:20:43 +00:00
|
|
|
<member><function>libxml_get_last_error</function></member>
|
|
|
|
<member><function>libxml_clear_errors</function></member>
|
2005-02-14 18:01:02 +00:00
|
|
|
</simplelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|