(PHP 5 >= 5.1.0, PHP 7, PHP 8)
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.
public close(): true
public expand(?DOMNode $baseNode = null): DOMNode|false
public static fromStream( resource $stream, ?string $encoding = null, int $flags = 0, ?string $documentUri = null ): static
public static fromString(string $source, ?string $encoding = null, int $flags = 0): static
public static fromUri(string $uri, ?string $encoding = null, int $flags = 0): static
public getAttribute(string $name): ?string
public getAttributeNo(int $index): ?string
public getAttributeNs(string $name, string $namespace): ?string
public getParserProperty(int $property): bool
public isValid(): bool
public lookupNamespace(string $prefix): ?string
public moveToAttribute(string $name): bool
public moveToAttributeNo(int $index): bool
public moveToAttributeNs(string $name, string $namespace): bool
public moveToElement(): bool
public moveToFirstAttribute(): bool
public moveToNextAttribute(): bool
public next(?string $name = null): bool
public static open(string $uri, ?string $encoding = null, int $flags = 0): XMLReader
public open(string $uri, ?string $encoding = null, int $flags = 0): bool
public read(): bool
public readInnerXml(): string
public readOuterXml(): string
public readString(): string
public setParserProperty(int $property, bool $value): bool
public setRelaxNGSchema(?string $filename): bool
public setRelaxNGSchemaSource(?string $source): bool
public setSchema(?string $filename): bool
public static XML(string $source, ?string $encoding = null, int $flags = 0): XMLReader
public XML(string $source, ?string $encoding = null, int $flags = 0): bool}
The number of attributes on the node
The base URI of the node
Depth of the node in the tree, starting at 0
Indicates if node has attributes
Indicates if node has a text value
Indicates if attribute is defaulted from DTD
Indicates if node is an empty element tag
The local name of the node
The qualified name of the node
The URI of the namespace associated with the node
The node type for the node
The prefix of the namespace associated with the node
The text value of the node
The xml:lang scope which the node resides
XMLReader::NONENo node type
XMLReader::ELEMENTStart element
XMLReader::ATTRIBUTEAttribute node
XMLReader::TEXTText node
XMLReader::CDATACDATA node
XMLReader::ENTITY_REFEntity Reference node
XMLReader::ENTITYEntity Declaration node
XMLReader::PIProcessing Instruction node
XMLReader::COMMENTComment node
XMLReader::DOCDocument node
XMLReader::DOC_TYPEDocument Type node
XMLReader::DOC_FRAGMENTDocument Fragment node
XMLReader::NOTATIONNotation node
XMLReader::WHITESPACEWhitespace node
XMLReader::SIGNIFICANT_WHITESPACESignificant Whitespace node
XMLReader::END_ELEMENTEnd Element
XMLReader::END_ENTITYEnd Entity
XMLReader::XML_DECLARATIONXML Declaration node
XMLReader::LOADDTDLoad DTD but do not validate
XMLReader::DEFAULTATTRSLoad DTD and default attributes but do not validate
XMLReader::VALIDATELoad DTD and validate while parsing
XMLReader::SUBST_ENTITIESSubstitute entities and expand references
| Version | Description |
|---|---|
| 8.4.0 | The class constants are now typed. |
© 1997–2025 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/class.xmlreader.php