Php/func xml set notation decl handler
来自菜鸟教程
PHP xml_set_notation_decl_handler()函数
例
创建一个XML解析器,设置字符数据处理程序,设置符号声明处理程序,并解析XML文档:
<?php
// Create an XML 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>";
}
// Set the
character data handler
xml_set_character_data_handler($parser,"char");
// Set the
notation declaration handler
xml_set_notation_decl_handler($parser, "not_decl_handler");
$fp=fopen("note_notation.xml","r");
while ($data=fread($fp,4096)) {
// Parse XML data
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);
fclose($fp);
?>
定义和用法
xml_set_notation_decl_handler()函数指定当解析器在XML文档中找到符号声明时要调用的函数。
注意: 该处理程序参数也可以是包含对象引用和方法名称的数组。
句法
xml_set_notation_decl_handler(parser, handler)
参数值
| 参数 | 描述 |
|---|---|
| parser | 需要。指定要使用的XML解析器 |
| handler |
需要。指定用作事件处理程序的函数。该函数必须接受五个参数:
|
技术细节
| 返回值: | 成功则为真。失败时为假 |
| PHP版本: | 4.0+ |