If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > how to rename XML attribute?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-27-12, 02:21
tempe tempe is offline
Registered User
 
Join Date: Oct 2010
Posts: 27
how to rename XML attribute?

Hello

How to rename xml attribute for all xml data in one table

example
Quote:
<term id ="1">
<term>book</term>
<definition></definition>
</term>
I want to rename 'id' to 'term_id'

so that my new xml data will be look like this

Quote:
<term term_id ="1">
<term>book</term>
<definition></definition>
</term>
This is my basic code which I used to rename XML tag from definision to definition .

Quote:
update term
set term = xmlquery('copy $new := $TERM
modify( for $j in $new/term/definision
return do rename $j as "definition")
return $new' );
Which part do I have to alter which code above to rename attributes.

Thank You.
Reply With Quote
  #2 (permalink)  
Old 01-27-12, 07:43
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Did you have a chance to look at examples in the manual, particularly the XPath notation for attributes?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On