Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8935967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:06:38+00:00 2026-06-15T10:06:38+00:00

I have a Dataset which I created using Recursion in SQL, Parent UserId Child

  • 0

I have a Dataset which I created using Recursion in SQL,

Parent        UserId   Child     Reporting_To_UserId   Depth        id
Aditya         13     Abhishek     4                   0            13
Abhishek       4      Saurabh      6                   1            16
Abhishek       4      Mohinder     8                   1            17
Mohinder       8      Mohammad     14                  2            18
Saurabh        6      Rahul        1                   2            11
Saurabh        6      Amitesh      5                   2            12

Now I want to generate a XML which should look like this:-

 <Person name="Aditya" User_Id="13">

    <Person name="Abhishek" User_Id="4">

           <Person name="Mohinder" User_id="8">
               <Person name="Mohammad" User_id="14"/>
           </Person>         

           <Person name="Saurabh" User_Id="6">
              <Person name="Rahul" User_Id="1"/>
              <Person name="Amitesh" User_Id="5"/>
           </Person>

     </Person>

 </Person>

I want to create a Hierarchical XML using the Parent and Child relation from a Dataset.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:06:39+00:00Added an answer on June 15, 2026 at 10:06 am

    I think you could utilize following piece of code:

     protected void Page_Load(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();
            string connStr = @"Data Source=MY-PC\SQLExpress;Initial Catalog=DataDB;User Id=ME;Password=YourPassword;Trusted_Connection=True;";
            using (SqlConnection conn = new SqlConnection(connStr))
            {
                string sql = "Select MenuID, Text,Description, ParentID from UserInfo";
                SqlDataAdapter da = new SqlDataAdapter(sql, conn);
                da.Fill(ds);
                da.Dispose();
            }
            ds.DataSetName = "UserInfos"; //You can start directly from here as you have the dataset just mantain Parent and Child ID Proper
            ds.Tables[0].TableName = "UserInfo";
            DataRelation relation = new DataRelation("ParentChild",
             ds.Tables["UserInfo"].Columns["MenuID"],
             ds.Tables["UserInfo"].Columns["ParentID"], true);
    
            relation.Nested = true;
            ds.Relations.Add(relation);  //XmlDataSource1 is any source of xml you can have this in file also
            XmlDataSource1.Data = ds.GetXml(); //Here Dataset will automatically generate XML for u based on relations added
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a dataset in my visual studio project which is connected to
(Using Visual Studio 2005 / .NET 2.0) I have a DataSet which is being
I'm using a dataset. I have a table Adapter called PackageTableAdapter , which contains
I have the below SQL Script which is run from Excel VBA using ADO
I have created a data frame from a SQL query using the RODBC package.
I have developed a program (C#) which creates a SQL database using this code:
I have created a database and table using Visual Studio's SQL Server Compact 3.5
I have DataSet which has 3 columns. Name - insurance comp. name - treatmentDate
I have a 2-class dataset on which I should apply a binary classification algorithm.
I have a moderately sized dataset in excel from which I wish to extract

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.