0

I have a table with two columns

column_1 column_1
12345     12345
73255     73255
71377     71377 

Now i want to create an xml like

<header>
<value>12345</value>
<value>73255</value>
<value>71377</value>
<footer>

basically i need to use a select query and put any one of the fields into the values of xml.

could you please suggest how could this be done in an easiest way? much appreciate your help.

2
  • That depends on what kind of database you have and what command-line DB client you have available. Commented Oct 22, 2009 at 10:48
  • i am connecting to data base using sqlplus Commented Oct 22, 2009 at 12:52

1 Answer 1

1

imagine you have selected from the database and stored those columns in a file called "file"

#!/bin/bash
awk 'BEGIN{ print "<header>"}
NR>1{  print "<value>"$1"</value>" }
END{ print "<footer>"}' file

on the command line

# ./shell.sh
<header>
<value>12345</value>
<value>73255</value>
<value>71377</value>
<footer>
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.