Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Posts
    1,605

    Unanswered: 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 10:22.

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

  3. #3
    Join Date
    Jan 2003
    Posts
    1,605
    I have found one solution instead of "select" I used xquery:
    db2-fn:xmlcolumn('schema.table.column')

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •