xpath xpath is a language for finding information in an xml document
TRANSCRIPT
![Page 1: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/1.jpg)
XpathXpath
XPath is a language for finding information in an XML document.
![Page 2: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/2.jpg)
trainingtraining
http://www.w3schools.com/xpath/xpath_intro.asp
![Page 3: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/3.jpg)
Naviguer dans les documents XML avec XPathNaviguer dans les documents XML avec XPath
• Introduction• Les axes• Les filtres• Les prédicats• Les fonctions prédéfinies• Syntaxe abrégée
![Page 4: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/4.jpg)
Naviguer dans les documents XML avec XPathNaviguer dans les documents XML avec XPath
• Introduction• Les axes• Les filtres• Les prédicats• Les fonctions prédéfinies• Syntaxe abrégée
![Page 5: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/5.jpg)
IntroductionIntroduction
Chaque document XML est une instance d'un arbre XML. XPath est un langage général d'adressage dans cet arbre XML.
![Page 6: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/6.jpg)
RemarquesRemarques
Le nœud racine est unique et obligatoire
Il ne faut pas le confondre avec l'élément document, souvent appelé racine du document.
Cette distinction est justifiée par le fait que quatre types de nœuds différents peuvent être fils du nœud racine.
• le nœud déclaration de domaine
• les instructions de traitement
• les commentaires
• l'élément document qui est unique
Si les nœuds sont ordonnés, les attributs ne le sont pas, ainsi nous ne pourrons pas recherche le nième attributs.
![Page 7: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/7.jpg)
LocationPathLocationPath
http://www.w3.org/TR/xpath#NT-LocationPath
[1] LocationPath ::= RelativeLocationPath| AbsoluteLocationPath
[2] AbsoluteLocationPath ::= '/' RelativeLocationPath?| AbbreviatedAbsoluteLocationPath
[3] RelativeLocationPath ::= Step| RelativeLocationPath '/' Step| AbbreviatedRelativeLocationPath
Un RelativeLocationPath sert à sélectionner un ensemble de noeuds basés sur leur position par rapport au noeud contextuel.
Un AbsoluteLocationPath sert à sélectionner un ensemble de noeuds basées sur leur position dans le document par rapport au noeud racine.
![Page 8: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/8.jpg)
RécursivitéRécursivité
http://www.w3.org/TR/xpath#NT-LocationPath
[1] LocationPath ::= RelativeLocationPath| AbsoluteLocationPath
[2] AbsoluteLocationPath ::= '/' RelativeLocationPath?| AbbreviatedAbsoluteLocationPath
[3] RelativeLocationPath ::= Step| RelativeLocationPath '/' Step| AbbreviatedRelativeLocationPath
Un RelativeLocationPath sert à sélectionner un ensemble de noeuds basés sur leur position par rapport au noeud contextuel.
Un AbsoluteLocationPath sert à sélectionner un ensemble de noeuds basées sur leur position dans le document par rapport au noeud racine.
![Page 9: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/9.jpg)
ExempleExemple
/child::doc /child::chapter[position()=5]/ child::section[ position()=2] selects the second section of the fifth chapter of the doc document element
![Page 10: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/10.jpg)
ExempleExemple
child::para [position()=2][attribute::pe="warning"] selects the second para child of the context node if that child has a type attribute with value warning
![Page 11: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/11.jpg)
Naviguer dans les documents XML avec XPathNaviguer dans les documents XML avec XPath
• Le langage d’adressage utilise des chemins pour désigner un ensemble d’objets
• Une étape de localisation se fait en 3 temps : un axe, est un chemin à travers l'arbre du document, débutant au nœud origine et suivant une relation particulière entre les nœuds.
un filtre, qui spécifie le type du noeud obtenus par l'étape de localisation
0 ou n prédicats, qui sont des expressions arbitraires pour raffiner l'ensemble des noeuds
![Page 12: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/12.jpg)
ExemplesExemples
child::para[ position()=5][attribute::type="warning"] selects the fifth para child of the context node if that child has a type attribute with value warning
• Une étape de localisation se fait en 3 temps : • un axe, est un chemin à travers l'arbre du document,
débutant au nœud origine et suivant une relation particulière entre les nœuds.
• un filtre, qui spécifie le type du noeud obtenus par l'étape de localisation
• 0 ou n prédicats, qui sont des expressions arbitraires pour raffiner l'ensemble des noeuds
![Page 13: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/13.jpg)
Naviguer dans les documents XML avec XPathNaviguer dans les documents XML avec XPath
• Introduction• Les axes• Les filtres• Les prédicats• Les fonctions prédéfinies• Syntaxe abrégée
![Page 14: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/14.jpg)
AxisNameAxisName
Un AxisName est utilisé dans un Step pour identifier un chemin à suivre depuis un nœud donné vers les autres nœuds liés.
http://www.w3.org/TR/xpath#axes
AxisName ::= | 'ancestor'
| 'ancestor-or-self'| 'attribute'| 'child'| 'descendant'| 'descendant-or-self'| 'following'| 'following-sibling'| 'namespace'| 'parent'| 'preceding'| 'preceding-sibling'| 'self'
![Page 15: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/15.jpg)
| 'ancestor'| 'ancestor'
![Page 16: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/16.jpg)
| 'ancestor'| 'ancestor'
1
2
![Page 17: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/17.jpg)
'ancestor-or-self''ancestor-or-self'
![Page 18: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/18.jpg)
'ancestor-or-self''ancestor-or-self'
2
3
1
![Page 19: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/19.jpg)
| 'child'| 'child'
![Page 20: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/20.jpg)
| 'child'| 'child'
1 2
![Page 21: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/21.jpg)
| 'descendant'| 'descendant'
![Page 22: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/22.jpg)
| 'descendant'| 'descendant'
1 2
53 4
![Page 23: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/23.jpg)
| 'descendant-or-self'| 'descendant-or-self'
![Page 24: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/24.jpg)
| 'descendant-or-self'| 'descendant-or-self'
1
2 3
64 5
![Page 25: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/25.jpg)
| 'following'| 'following'
![Page 26: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/26.jpg)
| 'following'| 'following'
1
32
4
![Page 27: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/27.jpg)
| 'following-sibling'| 'following-sibling'
![Page 28: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/28.jpg)
| 'following-sibling'| 'following-sibling'
1 2
![Page 29: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/29.jpg)
| 'parent'| 'parent'
![Page 30: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/30.jpg)
| 'parent'| 'parent'
1
![Page 31: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/31.jpg)
| 'preceding'| 'preceding'
![Page 32: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/32.jpg)
| 'preceding'| 'preceding'
3
12
![Page 33: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/33.jpg)
| 'preceding-sibling'| 'preceding-sibling'
![Page 34: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/34.jpg)
| 'preceding-sibling'| 'preceding-sibling'
1
![Page 35: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/35.jpg)
| 'self'| 'self'
1
![Page 36: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/36.jpg)
AxisSpecifierAxisSpecifier
Un AxisSpecifier est soit un nom d'axe, soit une abréviation pour un nom d'axe. Il définit une direction de navigation à travers le document en définissant une liste ordonnée de nœuds qui peuvent être visités.
http://www.w3.org/TR/xpath#NT-AxisSpecifier
AxisSpecifier ::= AxisName '::' | AbbreviatedAxisSpecifier
http://www.w3.org/TR/xpath#NT-AbbreviatedAxisSpecifier
[13] AbbreviatedAxisSpecifier ::= '@'?
![Page 37: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/37.jpg)
ExempleExemple
ancestor::spécifie l'axe ancêtre
Preceding-sibling::Spécifie l'axe enfant précédent
@ spécifie l'axe attribut
![Page 38: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/38.jpg)
Naviguer dans les documents XML avec XPathNaviguer dans les documents XML avec XPath
• Introduction• Les axes• Les filtres• Les prédicats• Les fonctions prédéfinies• Syntaxe abrégée
![Page 39: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/39.jpg)
PredicatePredicate
Un prédicat est une expression qualificative utilisée pour sélectionner un sous ensemble des noeuds d'une ensemble de noeuds ou de Step.
http://www.w3.org/TR/xpath#predicates
[8] Predicate ::= '[' PredicateExpr ']' # noter les []
[9] PredicateExpr ::= Expr
![Page 40: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/40.jpg)
ExempleExemple
Para[ 1] ou Para[ position()=1]Le premier élément enfant <para> du noeud contextuel
para[ last()]le dernier élément enfant du noeud contextuel.
![Page 41: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/41.jpg)
Naviguer dans les documents XML avec XPath (3)Naviguer dans les documents XML avec XPath (3)
Les axes: self, child, parent,
descendant, descendant-or-self,
ancestor, ancestor-or-self,
preceding, preceding-sibling,
following, following-sibling, attribute
<AAA> <XXX> <DDD> <BBB/> <BBB/> <EEE/> <FFF/> </DDD> </XXX> <CCC> <DDD> <BBB/> <BBB id=“b”/> <GGG/> <FFF/> </DDD> </CCC> <CCC> <BBB name=“bbb”> <BBB id=“bbb”> <BBB/> </BBB> </BBB> </CCC> </AAA>
//CCC/self::*
![Page 42: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/42.jpg)
Naviguer dans les documents XML avec XPath (3)Naviguer dans les documents XML avec XPath (3)
Les axes: self, child, parent,
descendant, descendant-or-self,
ancestor, ancestor-or-self,
preceding, preceding-sibling,
following, following-sibling, attribute
<AAA> <XXX> <DDD> <BBB/> <BBB/> <EEE/> <FFF/> </DDD> </XXX> <CCC> <DDD> <BBB/> <BBB id=“b”/> <GGG/> <FFF/> </DDD> </CCC> <CCC> <BBB name=“bbb”> <BBB id=“bbb”> <BBB/> </BBB> </BBB> </CCC> </AAA>
//CCC/child::*
![Page 43: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/43.jpg)
Naviguer dans les documents XML avec XPath (3)Naviguer dans les documents XML avec XPath (3)
Les axes: self, child, parent,
descendant, descendant-or-self,
ancestor, ancestor-or-self,
preceding, preceding-sibling,
following, following-sibling, attribute
<AAA> <XXX> <DDD> <BBB/> <BBB/> <EEE/> <FFF/> </DDD> </XXX> <CCC> <DDD> <BBB/> <BBB id=“b”/> <GGG/> <FFF/> </DDD> </CCC> <CCC> <BBB name=“bbb”> <BBB id=“bbb”> <BBB/> </BBB> </BBB> </CCC> </AAA>
//CCC/parent::*
![Page 44: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/44.jpg)
Naviguer dans les documents XML avec XPath (3)Naviguer dans les documents XML avec XPath (3)
Les axes: self, child, parent,
descendant, descendant-or-self,
ancestor, ancestor-or-self,
preceding, preceding-sibling,
following, following-sibling, attribute
<AAA> <XXX> <DDD> <BBB/> <BBB/> <EEE/> <FFF/> </DDD> </XXX> <CCC> <DDD> <BBB/> <BBB id=“b”/> <GGG/> <FFF/> </DDD> </CCC> <CCC> <BBB name=“bbb”> <BBB id=“bbb”> <BBB/> </BBB> </BBB> </CCC> </AAA>
//DDD/descendant::*
![Page 45: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/45.jpg)
Naviguer dans les documents XML avec XPath (3)Naviguer dans les documents XML avec XPath (3)
Les axes: self, child, parent,
descendant, descendant-or-self,
ancestor, ancestor-or-self,
preceding, preceding-sibling,
following, following-sibling, attribute
<AAA> <XXX> <DDD> <BBB/> <BBB/> <EEE/> <FFF/> </DDD> </XXX> <CCC> <DDD> <BBB/> <BBB id=“b”/> <GGG/> <FFF/> </DDD> </CCC> <CCC> <BBB name=“bbb”> <BBB id=“bbb”> <BBB/> </BBB> </BBB> </CCC> </AAA>
//DDD/ancestor::*
![Page 46: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/46.jpg)
Naviguer dans les documents XML avec XPath (3)Naviguer dans les documents XML avec XPath (3)
Les axes: self, child, parent,
descendant, descendant-or-self,
ancestor, ancestor-or-self,
preceding, preceding-sibling,
following, following-sibling, attribute
<AAA> <XXX> <DDD> <BBB/> <BBB/> <EEE/> <FFF/> </DDD> </XXX> <CCC> <DDD> <BBB/> <BBB id=“b”/> <GGG/> <FFF/> </DDD> </CCC> <CCC> <BBB name=“bbb”> <BBB id=“bbb”> <BBB/> </BBB> </BBB> </CCC> </AAA>
//GGG/preceding::*
![Page 47: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/47.jpg)
Naviguer dans les documents XML avec XPath (3)Naviguer dans les documents XML avec XPath (3)
Les axes: self, child, parent,
descendant, descendant-or-self,
ancestor, ancestor-or-self,
preceding, preceding-sibling,
following, following-sibling, attribute
<AAA> <XXX> <DDD> <BBB/> <BBB/> <EEE/> <FFF/> </DDD> </XXX> <CCC> <DDD> <BBB/> <BBB id=“b”/> <GGG/> <FFF/> </DDD> </CCC> <CCC> <BBB name=“bbb”> <BBB id=“bbb”> <BBB/> </BBB> </BBB> </CCC> </AAA>
//GGG/preceding-sibling::*
![Page 48: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/48.jpg)
Naviguer dans les documents XML avec XPath (3)Naviguer dans les documents XML avec XPath (3)
Les axes: self, child, parent,
descendant, descendant-or-self,
ancestor, ancestor-or-self,
preceding, preceding-sibling,
following, following-sibling, attribute
<AAA> <XXX> <DDD> <BBB/> <BBB/> <EEE/> <FFF/> </DDD> </XXX> <CCC> <DDD> <BBB/> <BBB id=“b”/> <GGG/> <FFF/> </DDD> </CCC> <CCC> <BBB name=“bbb”> <BBB id=“bbb”> <BBB/> </BBB> </BBB> </CCC> </AAA>
//*[attribute::id]
![Page 49: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/49.jpg)
Naviguer dans les documents XML avec XPathNaviguer dans les documents XML avec XPath
• Introduction• Les axes• Les filtres• Les prédicats• Les fonctions prédéfinies• Syntaxe abrégée
![Page 50: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/50.jpg)
FilterExprFilterExpr
FilterExpr est utilisé pour appliquer un ou plusieurs Predicates à un ensemble de noeuds, en sélectionnant un sous ensemble de ces noeuds satisfaisant certaines conditions.
http://www.w3.org/TR/xpath#NT-FilterExpr
[20] FilterExpr ::= PrimaryExpr| FilterExpr Predicate
![Page 51: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/51.jpg)
Naviguer dans les documents XML avec XPath (3)Naviguer dans les documents XML avec XPath (3)
Les axes: self, child, parent,
descendant, descendant-or-self,
ancestor, ancestor-or-self,
preceding, preceding-sibling,
following, following-sibling, attribute
Les filtres: /, *, element
Les prédicats: [expression], les opérations: +, -, *, div, mod, >, >=, <, <=, =, !=
Syntaxe abrégée: //, ., .., @
/AAA/*/DDD/*<AAA> <XXX> <DDD> <BBB/> <BBB/> <EEE/> <FFF/> </DDD> </XXX> <CCC> <DDD> <BBB/> <BBB id=“b”/> <GGG/> <FFF/> </DDD> </CCC> <CCC> <BBB name=“bbb”> <BBB id=“bbb”> <BBB/> </BBB> </BBB> </CCC> </AAA>
![Page 52: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/52.jpg)
Naviguer dans les documents XML avec XPathNaviguer dans les documents XML avec XPath
• Introduction• Les axes• Les filtres• Les prédicats• Les fonctions prédéfinies• Syntaxe abrégée
![Page 53: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/53.jpg)
Naviguer dans les documents XML avec XPath (3)Naviguer dans les documents XML avec XPath (3)
Les axes: self, child, parent,
descendant, descendant-or-self,
ancestor, ancestor-or-self,
preceding, preceding-sibling,
following, following-sibling, attribute
Les filtres: /, *, element
Les prédicats: [expression], les opérations: +, -, *, div, mod, >, >=, <, <=, =, !=
Syntaxe abrégée: //, ., .., @
//BBB[attribute::id=‘bbb’]<AAA> <XXX> <DDD> <BBB/> <BBB/> <EEE/> <FFF/> </DDD> </XXX> <CCC> <DDD> <BBB/> <BBB id=“b”/> <GGG/> <FFF/> </DDD> </CCC> <CCC> <BBB name=“bbb”> <BBB id=“bbb”> <BBB/> </BBB> </BBB> </CCC> </AAA>
![Page 54: Xpath XPath is a language for finding information in an XML document](https://reader035.vdocuments.mx/reader035/viewer/2022062219/551d9d8c497959293b8c0d3a/html5/thumbnails/54.jpg)
Syntaxe abrégéeSyntaxe abrégée
./toto self::toto
toto child::toto (et non toto)
../toto parent::toto
@titi attribute::titi
//toto /descendant-or-self::node()/child::toto
.//toto descendant-or-self::node()/child::toto
toto[2] child::toto[position() = 2]