Re: xml column/xpath w/ sql server

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Apr 5, 12:38 pm, Martin Honnen <mahotr...@xxxxxxxx> wrote:
Kenny wrote:
For the following xml, I want to the below query to update the second
Item element, based off of a that "closedMessage" Key. Any
suggestions? is there some way to make the "replace of" function more
specific than the way I'm using it? thanks in advance.

If you want to update the second Item element then I think you need

set userpreferencesxml.modify('
replace value of (/root/Item/Value/text())[1]

replace value of (/root/Item/Value/text())[2]
as XPath/XQuery indices start with 1.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Thanks. Is there a way to get that index value using any of the built
in xml functions? nodes() perhaps? or would I need to build some
recursive loop and do some i++ operation?

.