1

I'm trying to modify xml attribute in my table:

XML:

 <root>
      <object name="111">
        <fields>
          <field name="1">False</ofield>
          <field name="VIN">123</field>
         </fields>
     </object>
    </root>


UPDATE wftable
SET XML.modify('replace value of 
               (root/object[@name="111"]/fields/field/@name[.="VIN"])[1] 
               with "testNumber"')
WHERE id = 20889436

But I get as a result

<field name="testNumber">123</field>

Actually I just want to update xml node like this:

<field name="VIN">testNumber</field>

How can I modify my UPDATE query?

0

1 Answer 1

1

You need to specify the text() node of field as the node you want to update.

replace value of 
(root/object[@name="111"]/fields/field[@name="VIN"]/text())[1] 
with "testNumber"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.