PHP xml_set_unparsed_entity_decl_handler() function
Definition and Usage
The xml_set_unparsed_entity_decl_handler() function defines the function to be called when encountering an unparseable entity name (NDATA) declaration.
If the handler is successfully established, the function will return true; otherwise, it will return false.
Syntax
xml_set_unparsed_entity_decl_handler(parser,handler)
Parameters | Description |
---|---|
parser | Mandatory. Defines the XML parser to be used. |
handler | Mandatory. Defines a function. |
By handler The function defined by the parameter must have six parameters:
Parameters | Description |
---|---|
parser | Mandatory. Defines a variable containing the XML parser that calls the processor. |
name | Mandatory. Defines a variable containing the entity name. |
base |
Mandatory. Defines a variable containing the base for parsing the entity's system identifier (system_id). Currently, this parameter is usually set to an empty string. |
system_id | Mandatory. Defines a variable containing the system identifier of the entity. |
public_id | Mandatory. Defines a variable containing the public identifier of the entity. |
notation | Mandatory. Defines a variable containing the symbol that identifies the data type of the entity. |
Description
handler The parameter can also be an array containing object references and method names.
Example
<?php $parser=xml_parser_create(); function char($parser,$data) { } function unparsed_ent_handler($parser,$entname, $base,$sysID,$pubID,$notname) { print "$entname"; print "$sysID"; print "$pubID"; print "$notname"; } xml_set_unparsed_entity_decl_handler($parser, "unparsed_ent_handler"); $fp=fopen("test.xml","r"); while ($data=fread($fp,4096)) { xml_parse($parser,$data,feof($fp)) or die (sprintf("XML Error: %s at line %d", xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser))); } xml_parser_free($parser); ?>