We help IT Professionals succeed at work.

Find nodes and change values in a xml (mssql)

Medium Priority
745 Views
Last Modified: 2012-08-30
Hello.

Can someone help me with one thing.

I need help with
1. Create a store procedure that finds
all nodes with name "XXX" in a xml document and set
the value YYY in those nodes.

2. I need to create a sp that finds all nodes with a VALUE YYY
and replace that with a new value ZZZ
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2012

Commented:
Please post a sample Xml document and the final result.

Author

Commented:
I don't want it to be specific to the xml. I want it to find every node in the xml that has a specific value

for example
<root>
<test1>@r1</test1>
<a>
<test1>@r1</test1>
</a>

</root>

i now want to replace all @r1
with XXX for example.


<root>
<test1>XXX</test1>
<a>
<test1>XXX</test1>
 
</a>

</root>

Author

Commented:
Sorry that was for nr 2

for nr 1


<root>
<test1>x1</test1>
<a>
<test1>x2</test1>
</a>
</root>
Here I want to specify that I want to replace values in nodes with name test1 with value YYY
and get



<root>
<test1>YYY</test1>
<a>
<test1>YYY</test1>
</a>
</root>

Author

Commented:
I, men traveling and havet limiterad access tog internet.  Will check next week