(PHP 5 >= 5.1.0, PHP 7, PHP 8)
Introduction
L'extension XMLReader est un analyseur XML. L'analyseur fonctionne
comme un curseur qui parcourt le document et s'arrête sur chaque
nœud.
Synopsis de la classe
class
XMLReader
{
/* Constantes */
public
const
int
NONE;
public
const
int
ELEMENT;
public
const
int
ATTRIBUTE;
public
const
int
TEXT;
public
const
int
CDATA;
public
const
int
ENTITY_REF;
public
const
int
ENTITY;
public
const
int
PI;
public
const
int
COMMENT;
public
const
int
DOC;
public
const
int
DOC_TYPE;
public
const
int
DOC_FRAGMENT;
public
const
int
NOTATION;
public
const
int
WHITESPACE;
public
const
int
SIGNIFICANT_WHITESPACE;
public
const
int
END_ELEMENT;
public
const
int
END_ENTITY;
public
const
int
XML_DECLARATION;
public
const
int
LOADDTD;
public
const
int
DEFAULTATTRS;
public
const
int
VALIDATE;
public
const
int
SUBST_ENTITIES;
/* Propriétés */
public
int
$attributeCount;
public
string
$baseURI;
public
int
$depth;
public
bool
$hasAttributes;
public
bool
$hasValue;
public
bool
$isDefault;
public
bool
$isEmptyElement;
public
string
$localName;
public
string
$name;
public
string
$namespaceURI;
public
int
$nodeType;
public
string
$prefix;
public
string
$value;
public
string
$xmlLang;
/* Méthodes */
public
close(): true
public expand(?DOMNode
$baseNode =
null): DOMNode|false
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): bool|XMLReader
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): bool|XMLReader
}
Propriétés
- attributeCount
-
Le nombre d'attributs dans le nœud
- baseURI
-
La base URI du nœud
- depth
-
Profondeur du nœud dans l'arbre démarrant à 0
- hasAttributes
-
Indique si le nœud a des attributs
- hasValue
-
Indique si le nœud a une valeur de texte
- isDefault
-
Indique si l'attribut est par défaut à partir du DTD
- isEmptyElement
-
Indique si le nœud est un élément vide
- localName
-
Le nom local du nœud
- name
-
Le nœud qualifié du nœud
- namespaceURI
-
L'URI de l'espace de nom associé avec le nœud
- nodeType
-
Le type de nœud pour le nœud
- prefix
-
Le préfixe de l'espace de nom associé avec le nœud
- value
-
La valeur du texte du nœud
- xmlLang
-
La portée xml:lang dans lequel le nœud réside
Constantes pré-définies
Types de nœud XMLReader
XMLReader::NONE
-
Pas de type de nœud
XMLReader::ELEMENT
-
Élément de départ
XMLReader::ATTRIBUTE
-
Noeud Attribut
XMLReader::TEXT
-
Noeud texte
XMLReader::CDATA
-
Noeud CDATA
XMLReader::ENTITY_REF
-
Noeud de référence d'entité
XMLReader::ENTITY
-
Noeud de déclaration d'entité
XMLReader::PI
-
Noeud d'instruction de processus
-
Noeud de commentaire
XMLReader::DOC
-
Noeud document
XMLReader::DOC_TYPE
-
Noeud de type de document
XMLReader::DOC_FRAGMENT
-
Noeud de fragment de document
XMLReader::NOTATION
-
Noeud de notation
XMLReader::WHITESPACE
-
Noeud "espace"
XMLReader::SIGNIFICANT_WHITESPACE
-
Noeud "espace" significatif
XMLReader::END_ELEMENT
-
Élément de fin
XMLReader::END_ENTITY
-
Entité de fin
XMLReader::XML_DECLARATION
-
Noeud de déclaration XML
Options de l'analyseur XMLReader
XMLReader::LOADDTD
-
Charge une DTD mais ne la valide pas
XMLReader::DEFAULTATTRS
-
Charge une DTD et les attributs par défaut mais ne la valide pas
XMLReader::VALIDATE
-
Charge une DTD et valide le document au moment de l'analyse
XMLReader::SUBST_ENTITIES
-
Substitue les entités et étend les références
Sommaire
- XMLReader::close — Ferme l'entrée XMLReader
- XMLReader::expand — Retourne une copie du nœud courant comme un nœud d'objet DOM
- XMLReader::getAttribute — Récupère la valeur d'un attribut par nom
- XMLReader::getAttributeNo — Récupère la valeur d'un attribut par index
- XMLReader::getAttributeNs — Récupère la valeur d'un attribut par nom local et URI
- XMLReader::getParserProperty — Indique si la propriété spécifiée a été fixée
- XMLReader::isValid — Indique si le document analysé est valide
- XMLReader::lookupNamespace — Consulte l'espace de nom pour un préfixe
- XMLReader::moveToAttribute — Déplace un curseur à un attribut nommé
- XMLReader::moveToAttributeNo — Déplace le curseur à un attribut par index
- XMLReader::moveToAttributeNs — Déplace le curseur à un attribut d'espace de nom
- XMLReader::moveToElement — Positionne le curseur sur l'élément parent de l'attribut courant
- XMLReader::moveToFirstAttribute — Positionne le curseur sur le premier attribut
- XMLReader::moveToNextAttribute — Positionne le curseur sur le prochain attribut
- XMLReader::next — Déplace le curseur au prochain nœud en sautant tous les sous arbres
- XMLReader::open — Fixe le URI contenant le XML à analyser
- XMLReader::read — Déplace le curseur sur le prochain nœud du document
- XMLReader::readInnerXml — Lit le code XML du nœud courant
- XMLReader::readOuterXml — Lit le code XML du nœud courant, y compris lui-même
- XMLReader::readString — Lit le contenu du nœud courant sous forme de chaîne
- XMLReader::setParserProperty — Fixe des options pour l'analyseur
- XMLReader::setRelaxNGSchema — Fixe le nom du fichier ou l'URI pour le Schéma RelaxNG
- XMLReader::setRelaxNGSchemaSource — Spécifie le schéma RelaxNG
- XMLReader::setSchema — Valide le document avec XSD
- XMLReader::XML — Fixe les données contenant le XML à analyser