función de PHP xml_set_notation_decl_handler ()
PHP completa de Referencia XML
Definición y Uso
xml_set_notation_decl_handler () función se especifica cuando el analizador para encontrar los símbolos declarados en un documento XML se llama una función.
Si tiene éxito, la función devuelve TRUE. Si se produce un error, devuelve FALSO.
gramática
xml_set_notation_decl_handler(parser,handler)
参数 | 描述 |
---|---|
parser | 必需。规定要使用的 XML 解析器。 |
handler | 必需。规定当解析器找到符号声明时被调用的函数。 |
Por el parámetro de función "controlador" debe tener cinco parámetros definidos:
参数 | 描述 |
---|---|
parser | 必需。规定一个变量,包含调用处理器的 XML 解析器。 |
name | 必需。规定一个变量,包含符号声明名称。 |
base | 必需。规定解析符号声明的系统标识符(system_id)的基础。当前该参数通常都被设置为 NULL。 |
system_id | 必需。规定一个变量,包含符号声明的系统标识符。 |
public_id | 必需。规定一个变量,包含符号声明的公共标识符。 |
Notas y sugerencias
NOTA: controlador también puede ser un parámetro que contiene una serie de referencias a objetos y nombres de método.
Ejemplos
<?php
$parser=xml_parser_create();
function char($parser,$data)
{
echo $data;
}
function not_decl_handler($parser,$not,$base,$sysID,$pubID)
{
echo "$not<br />";
echo "$sysID<br />";
echo "$pubID<BR />";
}
xml_set_character_data_handler($parser,"char");
xml_set_notation_decl_handler($parser, "not_decl_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);
?>
$parser=xml_parser_create();
function char($parser,$data)
{
echo $data;
}
function not_decl_handler($parser,$not,$base,$sysID,$pubID)
{
echo "$not<br />";
echo "$sysID<br />";
echo "$pubID<BR />";
}
xml_set_character_data_handler($parser,"char");
xml_set_notation_decl_handler($parser, "not_decl_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);
?>
PHP completa de Referencia XML