Thanks HTH.

I usually proofread everything before I submit it just to make sure it is
clear, but you go the gist of what I needed.
That helped tremendously it was exactly what I was looking for.

Thanks,
Mike

On Tue, May 20, 2008 at 9:39 AM, Efran Cobisi <[EMAIL PROTECTED]>
wrote:

> Hi Mike,
>
> I am unsure if I understood correctly your requirements (there isn't any
> attribute inside your XPath query, isn't it?). However, below you can
> find an XPath/SQL query which retrieves both the title and the author
> text value for each book element:
>
> SELECT T.C.value('title[1]', 'nvarchar(max)') AS Title,
>   T.C.value('author[1]', 'nvarchar(max)') AS Author
> FROM @xml.nodes('/books/book') AS T(C)
>
> HTH
>
> --
> Efran Cobisi
> http://www.cobisi.com
>
> Mike Andrews wrote:
>
>>  This might be Off Topic but here goes:
>>
>> I have an XPATH query question regarding element names and how to retrieve
>> them in SQL Server 2005.
>> Specifically given this xml document or something similar:
>>
>> <books>
>>  <book>
>>    <title>The Way Things Are.</title>
>>    <author>Irene R. Gibson</author>
>>  </book>
>>  <book>
>>    <title>The Way Things Were.</title>
>>    <author>Kari D. Bednarz</author>
>>  </book>
>> </books>
>>
>> I want to be able to specify that I want all "title"s and all "author"s
>> within the same query.
>>
>> Here's what I have so far and I can't seem to find any examples of
>> anything
>> dealing with elements vs. attributes:
>>
>> SELECT T.C.value('.[text()]', 'varchar(255)') AS NodeText
>> FROM @xml.nodes('/books/book/*') AS T(C)
>>
>> Now, I realize that the text() method only produces the text.  However
>> I've
>> not been able to find a way to query the node text based on the name of
>> the
>> node.
>>
>> Any help would be appreciated.
>>
>> Thanks,
>> Mike
>>
>> ===================================
>> This list is hosted by DevelopMentor(R)  http://www.develop.com
>>
>> View archives and manage your subscription(s) at
>> http://discuss.develop.com
>>
>>
> ===================================
> This list is hosted by DevelopMentor(R)  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to