Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML for Database data

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi gurus
I have a requirement of getting data from Database and then packing it in xml and then send it as a message. Now I can think of two xml structures to do this:

1) This structure is like
<tablename><row><col1>value</col1></row><row><col2>value</col2></row></tablename>

The advantage with this approach is I have values of a particular row together. But disadvantages are, it is difficult to get a column value across all rows and also the column names get repeated across all rows.

2) In this approach the xml would typically look like
<tablename><col1><row>value</row><row>value</row></col2><col1><row>value</row><row>value</row></col2></tablename>

This solves the problem of column names getting repeated vis-a-vis approach one, but again retreiving all the columns of a given row is going to be cumbersome.

I wanted to know if there is any better approach other than these two. If yes, I would like to know that. If no, I would like to know which one of these approaches is good and why.

Thanks in Advance
Sudheer

 
Use a attribute like &quot;order&quot;
Code:
<tablename>
   <row>
      <col order='1'> value</col>
      <col order='2'> value</col>
   </row>
   <row>
      <col order='1'>value</col>
   </row>
</tablename>

You can now easily get all the columns of a single row or all the columns with the same order.

Good luck,

Jordi Reineman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top