Generating the correct XML from a self-referential table

B

Bob

I have a need to generate an XML based on a table in the DB. The table
contains self-referential data, e.g. it has these columns

employee_id
employee_name
employee_level
manager_id

manager_id is a foreign key to the employee_id. There can be many levels
of this relationships. How can I generate an XML document with the correct
hierarchy reflected? Since the levels are not known beforehand, I can't use
FOR XML clause in the SELECT statement. And a DataRelation with parent and
child from the same DataTable is not allowed in a DataSet.

Thanks a lot
Bob
 
V

Val Mazur \(MVP\)

Hi Bob,

If you need something nested, then you could load data into dataSet and than
save this dataSet into XML together with the relations
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top