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 display XML data from XML data field in CLP each tag into own line

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-19-09, 09:09
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
How to display XML data from XML data field in CLP each tag into own line

Hi,
in DB2 v9.5 I have table with XML data field. When I execute "select * from table" statement to display XML data from DB2 CLP I get one line output:
Code:
<employees><employee id="1"><name>Mark</name><office>IBM</office></employee><employee id="2"...
I would like to get output each tag into own row something like bellow:
Code:
<employees>
<employee id="1">
<name>Mark</name>
<office>IBM</office>
</employee>
in DB2 CLP, just to see contents of XML in human readable way. How?
Regards

Last edited by grofaty; 02-19-09 at 09:22.
Reply With Quote
  #2 (permalink)  
Old 02-19-09, 09:56
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You could use the REPLACE function to replace all substrings "></" with ">\n</".

What I am typically doing is to write the XML document into a file and view this in a browser. That gives me folding capabilities for larger documents.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 02-20-09, 02:15
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
I have found one solution instead of "select" I used xquery:
db2-fn:xmlcolumn('schema.table.column')
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