xml_error_string
(PHP 4, PHP 5)
xml_error_string — Get XML parser error string
Описание
string xml_error_string
( int $code
)
Gets the XML parser error string associated with the given code .
Возвращаемые значения
Returns a string with a textual description of the error code , or FALSE if no description was found.
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Обработка XML
- XML-анализатор
- utf8_decode
- utf8_encode
- xml_error_string
- xml_get_current_byte_index
- xml_get_current_column_number
- xml_get_current_line_number
- xml_get_error_code
- xml_parse_into_struct
- xml_parse
- xml_parser_create_ns
- xml_parser_create
- xml_parser_free
- xml_parser_get_option
- xml_parser_set_option
- xml_set_character_data_handler
- xml_set_default_handler
- xml_set_element_handler
- xml_set_end_namespace_decl_handler
- xml_set_external_entity_ref_handler
- xml_set_notation_decl_handler
- xml_set_object
- xml_set_processing_instruction_handler
- xml_set_start_namespace_decl_handler
- xml_set_unparsed_entity_decl_handler
Коментарии
Two notes in one.
Here is the combination of xml_get_error_code() and xml_error_string() to get the error printout as an echo response
Also, I tested before and after xml_parser_free() -- as expected, the error is indeed cleared with the free() so check your error before calling xml_parser_free()
Pushing a deadline or I would add in sample faulted xml for full p.o.c.
somebody else want to step up for that??
G
<?php
$p = xml_parser_create();
xml_parse_into_struct($p, $data, $vals, $index);
//This call prints error
echo 'ERROR if any '.xml_error_string(xml_get_error_code($p));
xml_parser_free($p);
echo "Index array\\n";
print_r($index);
echo "\\nVals array\\n";
print_r($vals);
//No Error left here to be printed
echo 'ERROR if any '.xml_error_string(xml_get_error_code($p));
exit;
?>