CakeFest 2024: The Official CakePHP Conference

xml_set_default_handler

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

xml_set_default_handlerImposta il gestore predefinito

Descrizione

xml_set_default_handler(resource $parser, callable $handler): bool

Imposta la funzione di gestione predefinita per il parser XML parser.

Elenco dei parametri

parser

Un riferimento al parser XML per impostare la funzione di gestione predefinita.

handler

handler è una stringa che contiene il nome di una funzione che deve esistere quando xml_parse() è chiamata per parser.

La funzione indicata da handler deve accettare due parametri:

handler(resource $parser, string $data)
parser
Il primo parametro, parser, è un riferimento al parser XML che chiama il gestore.
data
Il secondo parametro, data, contiene i dati carattere.Questo può essere la dichiarazione XML, la dichiarazione del tipo del documento, entità o altri dati per i quali non esistono altri gestori.

Se una funzione del gestore è impostata con una stringa vuota, oppure a false, il gestore in questione viene disabilitato.

Nota: Invece di un nome di funzione, può essere passato anche un array contenente un riferimento ad oggetto e un nome di metodo.

Valori restituiti

Restituisce true in caso di successo, false in caso di fallimento.

add a note

User Contributed Notes 2 notes

up
-2
phillip
18 years ago
it seems to me that in PHP5 the function defined as default-handler (using xml_set_default_handler()) doesen't get passed the cdata anymore:

i.e.:
xml_set_element_handler($this->parser, 'parseSTART', 'parseEND');
xml_set_default_handler($this->parser, 'parseDEFAULT');
function parseSTART() { ... }
function parseEND() { ... }
function parseDEFAULT() { ... }

under PHP5, parseDEFAULT will NOT get passed any cdata, but unter PHP4 it will. at least that's my take on the strange stuff (not) happening after migrating to PHP5.

my solution was to add a xml_set_character_data_handler($parser, 'parseDEFAULT'). it worked for me.
up
-3
anoril at anoril dot com
17 years ago
I have the same issue using two installation of PHP5: on accepts to use the default handler while the other only uses the character_data one.

Maybe a configuration problem...

;) Nonor.
To Top