首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

XMLReader (class)

介绍

(PHP 5 >= 5.1.0, PHP 7)

XMLReader扩展是一个XML Pull解析器。阅读器充当向文档流前进的光标,并停在路上的每个节点上。

类简介

XMLReader {

/ *常量* /

const int NONE = 0 ;

const int ELEMENT = 1 ;

const int ATTRIBUTE = 2 ;

const int TEXT = 3 ;

const int CDATA = 4 ;

const int ENTITY_REF = 5 ;

const int ENTITY = 6 ;

const int PI = 7 ;

const int COMMENT = 8 ;

const int DOC = 9 ;

const int DOC_TYPE = 10 ;

const int DOC_FRAGMENT = 11 ;

const int NOTATION = 12 ;

const int WHITESPACE = 13 ;

const int SIGNIFICANT_WHITESPACE = 14 ;

const int END_ELEMENT = 15 ;

const int END_ENTITY = 16 ;

const int XML_DECLARATION = 17 ;

const int LOADDTD = 1 ;

const int DEFAULTATTRS = 2 ;

const int VALIDATE = 3 ;

const int SUBST_ENTITIES = 4 ;

/ *属性* /

public readonly int $attributeCount ;

public readonly string $baseURI ;

public readonly int $depth ;

public readonly bool $hasAttributes ;

public readonly bool $hasValue ;

public readonly bool $isDefault ;

public readonly bool $isEmptyElement ;

public readonly string $localName ;

public readonly string $name ;

public readonly string $namespaceURI ;

public readonly int $nodeType ;

public readonly string $prefix ;

public readonly string $value ;

public readonly string $xmlLang ;

/* 方法 */

代码语言:javascript
复制
public bool close ( void )
代码语言:javascript
复制
public DOMNode expand ([ DOMNode $basenode ] )
代码语言:javascript
复制
public string getAttribute ( string $name )
代码语言:javascript
复制
public string getAttributeNo ( int $index )
代码语言:javascript
复制
public string getAttributeNs ( string $localName , string $namespaceURI )
代码语言:javascript
复制
public bool getParserProperty ( int $property )
代码语言:javascript
复制
public bool isValid ( void )
代码语言:javascript
复制
public string lookupNamespace ( string $prefix )
代码语言:javascript
复制
public bool moveToAttribute ( string $name )
代码语言:javascript
复制
public bool moveToAttributeNo ( int $index )
代码语言:javascript
复制
public bool moveToAttributeNs ( string $localName , string $namespaceURI )
代码语言:javascript
复制
public bool moveToElement ( void )
代码语言:javascript
复制
public bool moveToFirstAttribute ( void )
代码语言:javascript
复制
public bool moveToNextAttribute ( void )
代码语言:javascript
复制
public bool next ([ string $localname ] )
代码语言:javascript
复制
public bool open ( string $URI [, string $encoding [, int $options = 0 ]] )
代码语言:javascript
复制
public bool read ( void )
代码语言:javascript
复制
public string readInnerXML ( void )
代码语言:javascript
复制
public string readOuterXML ( void )
代码语言:javascript
复制
public string readString ( void )
代码语言:javascript
复制
public bool setParserProperty ( int $property , bool $value )
代码语言:javascript
复制
public bool setRelaxNGSchema ( string $filename )
代码语言:javascript
复制
public bool setRelaxNGSchemaSource ( string $source )
代码语言:javascript
复制
public bool setSchema ( string $filename )
代码语言:javascript
复制
public bool xml ( string $source [, string $encoding [, int $options = 0 ]] )

}

属性

attributeCount

节点上的属性数量

baseURI

节点的基本URI

depth

树中节点的深度,从0开始

hasAttributes

指示节点是否具有属性

hasValue

指示节点是否具有文本值

isDefault

指示属性是否来自DTD

isEmptyElement

指示节点是否为空元素标记

localName

节点的本地名称

name

节点的限定名称

namespaceURI

与节点关联的名称空间的URI

nodeType

节点的节点类型

prefix

与该节点关联的名称空间的前缀

value

节点的文本值

xmlLang

节点所在的xml:lang作用域

预定义的常量

XMLReader节点类型

XMLReader::NONE

没有节点类型

XMLReader::ELEMENT

开始元素

XMLReader::ATTRIBUTE

属性节点

XMLReader::TEXT

文本节点

XMLReader::CDATA

CDATA节点

XMLReader::ENTITY_REF

实体参考节点

XMLReader::ENTITY

实体声明节点

XMLReader::PI

处理指令节点

XMLReader::COMMENT

议论型节点

XMLReader::DOC

文档节点

XMLReader::DOC_TYPE

文档类型节点

XMLReader::DOC_FRAGMENT

文档片段节点

XMLReader::NOTATION

符号节点

XMLReader::WHITESPACE

空白节点

XMLReader::SIGNIFICANT_WHITESPACE

重要的空白节点

XMLReader::END_ELEMENT

结束元素

XMLReader::END_ENTITY

终端实体

XMLReader::XML_DECLARATION

XML声明节点

XMLReader解析器选项

XMLReader::LOADDTD

加载DTD但不验证

XMLReader::DEFAULTATTRS

加载DTD和默认属性,但不验证

XMLReader::VALIDATE

加载DTD并在解析时验证

XMLReader::SUBST_ENTITIES

替换实体并扩展引用

目录

  • XMLReader :: close - 关闭XMLReader输入
  • XMLReader :: expand - 将当前节点的副本作为DOM对象返回
  • XMLReader :: getAttribute - 获取指定属性的值
  • XMLReader :: getAttributeNo - 通过索引获取属性的值
  • XMLReader :: getAttributeNs - 通过localname和URI获取属性的值
  • XMLReader :: getParserProperty - 指示是否指定了属性
  • XMLReader :: isValid - 指示分析的文档是否有效
  • XMLReader :: lookupNamespace - 查找名称空间的前缀
  • XMLReader :: moveToAttribute - 将光标移动到指定的属性
  • XMLReader :: moveToAttributeNo - 通过索引将光标移动到某个属性
  • XMLReader :: moveToAttributeNs - 将光标移动到指定的属性
  • XMLReader :: moveToElement - 将光标定位在当前属性的父元素上
  • XMLReader :: moveToFirstAttribute - 将光标定位在第一个属性上
  • XMLReader :: moveToNextAttribute - 将光标定位在下一个属性上
  • XMLReader :: readInnerXML - 从当前节点检索XML
  • XMLReader :: readOuterXML - 从当前节点(包括其自身)检索XML
  • XMLReader :: readString - 以字符串形式读取当前节点的内容
  • XMLReader :: setParserProperty - 设置解析器选项
  • XMLReader :: setRelaxNGSchema - 设置RelaxNG模式的文件名或URI
  • XMLReader :: setRelaxNGSchemaSource - 设置包含RelaxNG Schema的数据
  • XMLReader :: setSchema - 根据XSD验证文档
  • XMLReader :: XML - 设置包含要解析的XML的数据

XMLReader::close →

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com