Node Selection

nodename [/...nodename]

selects all child nodes of the named node

nc

SQL: select @xXml.query('root')
produces:
<root>
  <item>
    <name tag="Tag1">Item One</name>
    <number>111</number>
  </item>
  <item>
    <name tag="Tag2">Item Two</name>
    <number>222</number>
  </item>
</root>
SQL: select @xXml.query('root/item')
produces:
<item>
  <name tag="Tag1">Item One</name>
  <number>111</number>
</item>
<item>
  <name tag="Tag2">Item Two</name>
  <number>222</number>
</item>
SQL: @xXml.query('root/item/name')
produces:
<name tag="Tag1">Item One</name>
<name tag="Tag2">Item Two</name>
/ [path]

selects from the root node

ec

SQL: select @xXml.query('/')
produces:
<root>
  <item>
    <name tag="Tag1">Item One</name>
    <number>111</number>
  </item>
  <item>
    <name tag="Tag2">Item Two</name>
    <number>222</number>
  </item>
</root>
SQL: select @xXml.query('/root/item/name')
produces:
<name tag="Tag1">Item One</name>
<name tag="Tag2">Item Two</name>
// [path]

selects nodes in the document from the current node that match the selection no matter where they are

nc

SQL: select @xXml.query('/root').query('//name')
produces:
<name tag="Tag1">Item One</name>
<name tag="Tag2">Item Two</name>
[path/].

selects the current nodes in the document

nc

SQL: select @xXml.query('/root/item/name/.')
produces:
<name tag="Tag1">Item One</name>
<name tag="Tag2">Item Two</name>
[path/]..

selects the parent of the current node in the document

nc

SQL: select @xXml.query('/root/item/name/..')
produces:
<item>
  <name tag="Tag1">Item One</name>
  <number>111</number>
</item>
<item>
  <name tag="Tag2">Item Two</name>
  <number>222</number>
</item>