XMLReader
class XMLReader (View source)
The XMLReader extension is an XML Pull parser. The reader acts as a cursor going forward on the document stream and stopping at each node on the way.
Constants
NONE |
No node type |
ELEMENT |
Start element |
ATTRIBUTE |
Attribute node |
TEXT |
Text node |
CDATA |
CDATA node |
ENTITY_REF |
Entity Reference node |
ENTITY |
Entity Declaration node |
PI |
Processing Instruction node |
COMMENT |
Comment node |
DOC |
Document node |
DOC_TYPE |
Document Type node |
DOC_FRAGMENT |
Document Fragment node |
NOTATION |
Notation node |
WHITESPACE |
Whitespace node |
SIGNIFICANT_WHITESPACE |
Significant Whitespace node |
END_ELEMENT |
End Element |
END_ENTITY |
End Entity |
XML_DECLARATION |
XML Declaration node |
LOADDTD |
Load DTD but do not validate |
DEFAULTATTRS |
Load DTD and default attributes but do not validate |
VALIDATE |
Load DTD and validate while parsing |
SUBST_ENTITIES |
Substitute entities and expand references |
Properties
int read-only | $attributeCount | The number of attributes on the node |
|
string read-only | $baseURI | The base URI of the node |
|
int read-only | $depth | Depth of the node in the tree, starting at 0 |
|
bool read-only | $hasAttributes | Indicates if node has attributes |
|
bool read-only | $hasValue | Indicates if node has a text value |
|
bool read-only | $isDefault | Indicates if attribute is defaulted from DTD |
|
bool read-only | $isEmptyElement | Indicates if node is an empty element tag |
|
string read-only | $localName | The local name of the node |
|
string read-only | $name | The qualified name of the node |
|
string read-only | $namespaceURI | The URI of the namespace associated with the node |
|
int read-only | $nodeType | The node type for the node |
|
string read-only | $prefix | The prefix of the namespace associated with the node |
|
string read-only | $value | The text value of the node |
|
string read-only | $xmlLang | The xml:lang scope which the node resides |
Methods
Close the XMLReader input
Get the value of a named attribute
Get the value of an attribute by index
Get the value of an attribute by localname and URI
Indicates if specified property has been set
Indicates if the parsed document is valid
Lookup namespace for a prefix
Move cursor to an attribute by index
Move cursor to a named attribute
Move cursor to a named attribute
Position cursor on the parent Element of current Attribute
Position cursor on the first Attribute
Position cursor on the next Attribute
Set the URI containing the XML to parse
Move to next node in document
Move cursor to next node skipping all subtrees
Retrieve XML from current node
Retrieve XML from current node, including it self
Reads the contents of the current node as a string
Validate document against XSD
Set parser options
Set the filename or URI for a RelaxNG Schema
Set the data containing a RelaxNG Schema
Set the data containing the XML to parse
No description
No description
Details
bool
close()
Close the XMLReader input
string|null
getAttribute(string $name)
Get the value of a named attribute
string|null
getAttributeNo(int $index)
Get the value of an attribute by index
string|null
getAttributeNs(string $name, string $namespace)
Get the value of an attribute by localname and URI
bool
getParserProperty(int $property)
Indicates if specified property has been set
bool
isValid()
Indicates if the parsed document is valid
string|null
lookupNamespace(string $prefix)
Lookup namespace for a prefix
bool
moveToAttributeNo(int $index)
Move cursor to an attribute by index
bool
moveToAttribute(string $name)
Move cursor to a named attribute
bool
moveToAttributeNs(string $name, string $namespace)
Move cursor to a named attribute
bool
moveToElement()
Position cursor on the parent Element of current Attribute
bool
moveToFirstAttribute()
Position cursor on the first Attribute
bool
moveToNextAttribute()
Position cursor on the next Attribute
static XMLReader|bool
open(string $uri, string $encoding = null, int $flags = 0)
Set the URI containing the XML to parse
bool
read()
Move to next node in document
bool
next(string $name = null)
Move cursor to next node skipping all subtrees
string
readInnerXml()
Retrieve XML from current node
string
readOuterXml()
Retrieve XML from current node, including it self
string
readString()
Reads the contents of the current node as a string
bool
setSchema(string $filename)
Validate document against XSD
bool
setParserProperty(int $property, bool $value)
Set parser options
bool
setRelaxNGSchema(string $filename)
Set the filename or URI for a RelaxNG Schema
bool
setRelaxNGSchemaSource(string $source)
Set the data containing a RelaxNG Schema
static XMLReader|bool
XML(string $source, string $encoding = null, int $flags = 0)
Set the data containing the XML to parse
DOMNode|false
expand(null|DOMNode $baseNode = null)
Returns a copy of the current node as a DOM object
static XMLReader
fromUri(string $uri, string|null $encoding = null, int $flags = 0)
No description
static XMLReader
fromStream($stream, string|null $encoding = null, int $flags = 0, string|null $documentUri = null)
No description
static XMLReader
fromString(string $source, string|null $encoding = null, int $flags = 0)
No description