PHP xml_set_notation_decl_handler() 函数

PHP 教程 · 2019-01-30 20:56:27

定义和用法

xml_set_notation_decl_handler() 函数规定当解析器在 XML 文档中找到符号声明时被调用的函数。

如果成功,该函数则返回 TRUE。如果失败,则返回 FALSE。

语法


xml_set_notation_decl_handler(parser,handler)


参数 描述
parser 必需。规定要使用的 XML 解析器。
handler 必需。规定当解析器找到符号声明时被调用的函数。

由 "handler" 参数规定的函数必须有五个参数:

参数 描述
parser 必需。规定一个变量,包含调用处理器的 XML 解析器。
name 必需。规定一个变量,包含符号声明名称。
base 必需。规定解析符号声明的系统标识符(system_id)的基础。当前该参数通常都被设置为 NULL。
system_id 必需。规定一个变量,包含符号声明的系统标识符。
public_id 必需。规定一个变量,包含符号声明的公共标识符。

提示和注释

注释:handler 参数也可以是一个包含对象引用和方法名的数组。

实例


<?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);
?>


点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

The Algorithmic Beauty of Plants

The Algorithmic Beauty of Plants

Przemyslaw Prusinkiewicz、Aristid Lindenmayer / Springer / 1996-4-18 / USD 99.00

Now available in an affordable softcover edition, this classic in Springer's acclaimed Virtual Laboratory series is the first comprehensive account of the computer simulation of plant development. 150......一起来看看 《The Algorithmic Beauty of Plants》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

随机密码生成器
随机密码生成器

多种字符组合密码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具