Tutoriel XML

ACCUEIL XML Introduction XML XML Comment utiliser Arbre XML Syntaxe XML Éléments XML Attributs XML Espaces de noms XML Affichage XML Requête HTTP XML Analyseur XML DOM XML XPath XML XML XSLT XQuery XML XMLXLink Validateur XML DTD XML Schéma XML Serveur XML Exemples XML XML Quiz Certificat XML

XMLAJAX

Présentation d'AJAX AJAX XMLHttp Requête AJAX Réponse AJAX Fichier XML AJAX PHP AJAX ASP AJAX Base de données AJAX Applications AJAX Exemples AJAX

DOM XML

Présentation du DOM Nœuds DOM Accès au DOM Informations sur le nœud DOM Liste des nœuds DOM Traversée du DOM Navigation DOM DOM Obtenir des valeurs Nœuds de changement DOM DOM Supprimer les nœuds DOM Remplacer les nœuds DOM Créer des nœuds DOM Ajouter des nœuds Nœuds de clonage DOM Exemples DOM

Tutoriel XPath

Présentation de XPath Nœuds XPath Syntaxe XPath Axes XPath Opérateurs XPath Exemples XPath

Tutoriel XSLT

Présentation de XSLT Langages XSL Transformation XSLT XSLT <modèle> XSLT <valeur-de> XSLT <pour-chaque> XSLT <sort> XSLT <si> XSLT <choisir> Appliquer XSLT XSLT sur le client XSLT sur le serveur XSLT Éditer XML Exemples XSLT

Tutoriel XQuery

Présentation de XQuery Exemple XQuery XQuery FLWOR XQuery HTML Termes XQuery Syntaxe XQuery Ajouter XQuery Sélection XQuery Fonctions XQuery

DTD XML

Présentation de la DTD Blocs de construction DTD Éléments DTD Attributs DTD Éléments DTD vs Attr Entités DTD Exemples de DTD

Schéma XSD

Présentation XSD Comment XSD XSD <schéma> Éléments XSD Attributs XSD Restrictions XSD

Complexe XSD

Éléments XSD XSD vide Éléments XSD uniquement Texte XSD uniquement XSD Mixte Indicateurs XSD XSD <tout> XSD <anyAttribute> Remplacement XSD Exemple XSD

Données XSD

Chaîne XSD Date XSD Numérique XSD Divers XSD Référence XSD

Services Web

Services XML XMLWSDL SAVON XML XML RDF XML RSS

Les références

Types de nœuds DOM Nœud DOM Liste de nœuds DOM DOM NamedNodeMap Documents DOM Élément DOM Attribut DOM Texte DOM DOM CDATA DOM Comment DOM XMLHttpRequest Analyseur DOM Éléments XSLT Fonctions XSLT/XPath

Axes XPath


L'exemple de document XML

Nous utiliserons le document XML suivant dans les exemples ci-dessous.

<?xml version="1.0" encoding="UTF-8"?>

<bookstore>

<book>
  <title lang="en">Harry Potter</title>
  <price>29.99</price>
</book>

<book>
  <title lang="en">Learning XML</title>
  <price>39.95</price>
</book>

</bookstore>

Axes XPath

Un axe représente une relation avec le nœud de contexte (actuel) et est utilisé pour localiser les nœuds par rapport à ce nœud sur l'arbre.

AxisName Result
ancestor Selects all ancestors (parent, grandparent, etc.) of the current node
ancestor-or-self Selects all ancestors (parent, grandparent, etc.) of the current node and the current node itself
attribute Selects all attributes of the current node
child Selects all children of the current node
descendant Selects all descendants (children, grandchildren, etc.) of the current node
descendant-or-self Selects all descendants (children, grandchildren, etc.) of the current node and the current node itself
following Selects everything in the document after the closing tag of the current node
following-sibling Selects all siblings after the current node
namespace Selects all namespace nodes of the current node
parent Selects the parent of the current node
preceding Selects all nodes that appear before the current node in the document, except ancestors, attribute nodes and namespace nodes
preceding-sibling Selects all siblings before the current node
self Selects the current node


Expression de chemin d'emplacement

Un chemin de localisation peut être absolu ou relatif.

Un chemin de localisation absolu commence par une barre oblique (/) et un chemin de localisation relatif ne le fait pas. Dans les deux cas, le chemin de localisation consiste en une ou plusieurs étapes, chacune séparée par une barre oblique :

An absolute location path:

/step/step/...

A relative location path:

step/step/...

Chaque étape est évaluée par rapport aux nœuds de l'ensemble de nœuds actuel.

Une étape consiste à :

  • un axe (définit la relation arborescente entre les nœuds sélectionnés et le nœud courant)
  • un test de nœud (identifie un nœud dans un axe)
  • zéro ou plusieurs prédicats (pour affiner davantage l'ensemble de nœuds sélectionné)

La syntaxe d'une étape de localisation est :

axisname::nodetest[predicate]

Exemples

Example Result
child::book Selects all book nodes that are children of the current node
attribute::lang Selects the lang attribute of the current node
child::* Selects all element children of the current node
attribute::* Selects all attributes of the current node
child::text() Selects all text node children of the current node
child::node() Selects all children of the current node
descendant::book Selects all book descendants of the current node
ancestor::book Selects all book ancestors of the current node
ancestor-or-self::book Selects all book ancestors of the current node - and the current as well if it is a book node
child::*/child::price Selects all price grandchildren of the current node