XML -zelfstudie

XML HOME XML-introductie XML Hoe te gebruiken XML-structuur XML-syntaxis XML-elementen XML-kenmerken XML-naamruimten XML-weergave XML HTTP-verzoek XML-parser XML-DOM XML XPath XML XSLT XML XQuery XML XLink XML-validator XML-DTD XML Schema XML-server XML-voorbeelden XML-quiz XML-certificaat

XML AJAX

Ajax-introductie AJAX XMLHttp Ajax-verzoek Ajax-reactie AJAX XML-bestand AJAX PHP Ajax ASP AJAX-database AJAX-toepassingen Ajax-voorbeelden

XML-DOM

DOM-introductie DOM-knooppunten DOM-toegang DOM Node Info Lijst met DOM-knooppunten DOM doorkruisen DOM-navigatie DOM Waarden ophalen DOM-wijzigingsknooppunten DOM Knooppunten verwijderen DOM Knooppunten vervangen DOM Knooppunten maken DOM Knooppunten toevoegen DOM-kloonknooppunten DOM-voorbeelden

XPath- zelfstudie

XPath-introductie XPath-knooppunten XPath-syntaxis XPath-assen XPath-operators XPath-voorbeelden

XSLT- zelfstudie

XSLT-introductie XSL-talen XSLT-transformatie XSLT <sjabloon> XSLT <waarde-van> XSLT <voor elk> XSLT <sorteren> XSLT <if> XSLT <kiezen> XSLT toepassen XSLT op de client XSLT op de server XSLT Bewerk XML XSLT-voorbeelden

XQuery- zelfstudie

XQuery-introductie XQuery-voorbeeld XQuery FLWOR XQuery HTML XQuery-voorwaarden XQuery-syntaxis XQuery toevoegen XQuery selecteren XQuery-functies

XML -DTD

DTD Introductie DTD-bouwstenen DTD-elementen DTD-kenmerken DTD Elements vs Attr DTD-entiteiten DTD-voorbeelden

XSD- schema

XSD-introductie XSD Hoe kan ik? XSD <schema> XSD-elementen XSD-kenmerken XSD-beperkingen

XSD- complex

XSD-elementen XSD Leeg Alleen XSD-elementen Alleen XSD-tekst XSD gemengd XSD-indicatoren XSD <elke> XSD <anyAttribute> XSD-vervanging XSD-voorbeeld

XSD- gegevens

XSD-string XSD-datum XSD Numeriek XSD Diversen XSD-referentie

Webservices _

XML-services XML-WSDL XML SOAP XML-RDF XML-RSS

Referenties

Typen DOM-knooppunten DOM Node DOM-knooppuntlijst DOM NamedNodeMap DOM-document DOM-element DOM-kenmerk DOM-tekst DOM CDATA DOM-opmerking DOM XMLHttpRequest DOM-parser XSLT-elementen XSLT/XPath-functies

XPath- assen


Het XML-voorbeelddocument

We zullen het volgende XML-document gebruiken in de onderstaande voorbeelden.

<?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>

XPath-assen

Een as vertegenwoordigt een relatie met het (huidige) knooppunt in de context en wordt gebruikt om knooppunten te lokaliseren ten opzichte van dat knooppunt in de boom.

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


Locatie Pad Expressie

Een locatiepad kan absoluut of relatief zijn.

Een absoluut locatiepad begint met een schuine streep ( / ) en een relatief locatiepad niet. In beide gevallen bestaat het locatiepad uit een of meer stappen, elk gescheiden door een schuine streep:

An absolute location path:

/step/step/...

A relative location path:

step/step/...

Elke stap wordt geëvalueerd ten opzichte van de knooppunten in de huidige knooppuntenset.

Een stap bestaat uit:

  • een as (definieert de boomrelatie tussen de geselecteerde knooppunten en het huidige knooppunt)
  • een knoop-test (identificeert een knoop binnen een as)
  • nul of meer predikaten (om de geselecteerde node-set verder te verfijnen)

De syntaxis voor een locatiestap is:

axisname::nodetest[predicate]

Voorbeelden

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