XPath and XQuery

Ok so I am finally getting around to talking a little about XPath and XQuery. Sorry for the delay. Note that this was information I got on my first day in XML training. I am sure there will be a lot more information that I learn and pass on to you.

XPath is actually a part of the Extensible Stylesheet Language (XSL). It became so popular that its use has be expanded for XML purposes. XPath is a language that allows you to specify a path that will return certain parts of an XML document. It is very popular. And it is 10 years old. Here is the important symbology in the XPath language:


  • / = document
  • * = element
  • text() = PCDATA
  • @* = attribute
Now let's move on to XQuery. About 80% of XQuery is just XPath syntax. It is very similar to SQL. It is used to interrogate an XML file and produce a subset in XML format. The most common pattern in XQuery is as follows:

for ... in ...
where ...
order by ...
return ...