xml_error_string

(PHP 4, PHP 5, PHP 7, PHP 8)

xml_error_stringLit le message d'erreur de l'analyseur XML

Description

xml_error_string(int $error_code): ?string

Lit le message d'erreur de l'analyseur XML associé avec le code error_code donné.

Liste de paramètres

error_code

Un code erreur provenant de xml_get_error_code().

Valeurs de retour

Retourne une chaîne représentant la description de l'erreur error_code, ou null si aucune description n'est trouvée.

Voir aussi

add a note add a note

User Contributed Notes 1 note

up
0
greg at getnetez dot com
12 years ago
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;
?>
To Top