Last Updated: 2008

Context = point in DOM tree
.	Current context (like DOS)
/	Child seperator (like DOS)
//	Recursive Descent
*	Element Wildcard (somepattern* is not allowed, just * on its own?)
@	Attribute Wildcard
@name	Attribute
:	Namespace seperator (Note: *:elementName is not supported)
()	Groups
[expr]	Filter
[n]	Index
+	\
-	 |
div	 }	Math
*	 |
mod	/
|	Set union

Examples:
book/title	All title elements that appear directly under a book element where the book element is directly under the current context. Identical to ./book/title

book/@title	All book elemenents with a title attribute where the book element is immediately under the current context

book[@title="Of Mice And Men"] All the book elements directly under the current context 
		whose title attribute exactly matches 'Of Mice and Men'

book[0]		First book element directly under the current context

book/title[0]	First title element OF EACH book elemenet directly under the current context

(book/title)[0]	First title element of the first book element under the current context (?? how does this differ from book[0]/title[0] ??)

book[last()]	Last book element directly under the current context
book[index() < 10]
		First 10 book elements under the current context

library//title	All title elements that appear any number of levels under a library element where the library element is immediately under the current context

library/*/title All title elements that appear as grandchildren of a library element where the library element is directly under the current context

.//title	All title elements that appear under the current context. This is not the same as //title which means ??

book/*		All elements that appear under book

book[title][author][publishingDate]
book[title and author and publishingDate]
		Only book elements that have all three title, author and publishingDate elements (wtle...)
book[(title or author) and publishingData]
		Only book elements that have a publishingDate and title or have a publishingDate and author
book[author and not(publishingDate)]
		Only book elements that have an author but no publishingDate. Note that not() is a function, not and operand and therefore need brackets round its argument)
title[.="Once upon a time"]
		Only title elements whose complete text is 'Once upon a time'
book[@author = /favoriteAuthor]
		Only book elements under the current context whose author attribute matches the text of the favoriteAuthor element from under the root context
(book | video)/Title="Alien"
		book and video elements under the current context whose title element's text is 'Alien'


Default namespace problem in .NET. Example XML:

<?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns:x="urn:schemas-microsoft-com:office:excel"
 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:html="http://www.w3.org/TR/REC-html40">
 <Worksheet ss:Name="NIRates">
  <Table ss:ExpandedColumnCount="3" ss:ExpandedRowCount="4" x:FullColumns="1"
   x:FullRows="1">
   <Column ss:Index="3" ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="96.75"/>
   <Row>
    <Cell><Data ss:Type="String">Key</Data></Cell>
    <Cell><Data ss:Type="String">Value</Data></Cell>
    <Cell><Data ss:Type="String">Date Effective</Data></Cell>
   </Row>
  </Table>
 </Worksheet>
</Workbook>

This code does not work:

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
            nsmgr.AddNamespace(String.Empty, "urn:schemas-microsoft-com:office:spreadsheet");
            nsmgr.AddNamespace("ss", "urn:schemas-microsoft-com:office:spreadsheet");
            nsmgr.AddNamespace("x", "urn:schemas-microsoft-com:office:excel");
            nsmgr.AddNamespace("o", "urn:schemas-microsoft-com:office:office");
            nsmgr.AddNamespace("html", "http://www.w3.org/TR/REC-html40");

            XmlNodeList tables = xmlDoc.DocumentElement.SelectNodes(".//Table", nsmgr);

You have to name the default namespace, i.e.
	    XmlNodeList tables = xmlDoc.DocumentElement.SelectNodes(".//ss:Table", nsmgr);