Before leaning FOR XML PATH option and XQuery, today, we'll learn about XPath Expression. This post will go over some XPath terminologies. Next post we'll look at the XPath syntax and work through some examples. If you want to learn more about XPath, please read the W3C XPath documentation here. W3schools website also has a good tutorial here.
Xpath (XML Path Language)
Is a standard for define path to element in XML fragments/documents.
Like a query language for XML
Expressed in hierarchical way (like path in UNIX file system)
Used in XQuery, XSLT, Xpointer, XML Schema
Level are delimited with / character
By default every column are element
Prefix the column alias with @ character to covert column to attribute-centric formatting.
XPath Nodes:
Root
Element
Attribute
Text
Namespace
Comment
Processing Instruction
XPath Axis: defines how a node-set(contain one or more node) is related to the current node.
Below are XPath Axes:
Ancestor
Ancestor-or-self
Attribute
Child
Descendant
Descendant-or-self
Following
Following-sibling
Namespace
Parent
Preceding
Preceding-sibling
Self
Below is a drawing that summarize the axes. The drawing is not mine. I get the drawing from this website.
Reference:
W3Schools Xpath Tutorial
W3C Xpath 1.0
W3C Xpath 2.0
No comments:
Post a Comment