XML: exist method

enrique_aeo
enrique_aeo used Ask the Experts™
on
Hi experts, I am attaching 2 files
1. Shows the result of a table
2. Shows the result of a query
I do not understand this code
InvoiceList / Invoice ') = 1

queryXML.jpg
resultXML.jpg
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2015
Commented:
It's called XPath (http://www.w3schools.com/xpath/) and it's a means of selecting nodes within an Xml document. Think of it much the same way you type in directory paths at the command line--you start at some root directory (root node) and traverse deeper into the directory heirarchy (subdirectories). In your code, the command says to select the Invoice node which is found under the InvoiceList node.

As far as the exist() method, it is specific to SQL Server and XQuery. The exist() method returns 1 if the node described by the specified XPath can be found; otherwise zero (0) is returned. Your overall query will return the StoreName only where the XML column contains a node like:
<InvoiceList>
    <Invoice>
        [Some Data]
    </Invoice>
</InvoiceList>

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial