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 7731995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:37:15+00:00 2026-06-01T06:37:15+00:00

I have a on memory Datatable like this. I want to produce xml file

  • 0

I have a on memory Datatable like this.

datatable

I want to produce xml file like this.

xml

The URL (e.g. http:\www.mymusicwebsite.com\songs) will always be the same.
Could anyone teach me how do I achieve this ?

Thanks A Lot.

L

  • 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-01T06:37:16+00:00Added an answer on June 1, 2026 at 6:37 am

    Using LINQ-to-XML:

    // test items set, you need change to the column accessor
    // like dataTable.Rows[2] or dataTable.Rows["fileName"]
    // or row.Field<string>("filename") as noted by Mentoliptus
    IList<string> items = new List<string> { "song1.mp3", "song2.mp3", "song3.mp3" };
    
    XmlWriterSettings xws = new XmlWriterSettings();
    xws.OmitXmlDeclaration = true;
    xws.Indent = true;
    
    // You can output to file or even in a string
    using (var stream = File.Create(@"C:\test.xml"))
    using (XmlWriter xw = XmlWriter.Create(stream, xws))
    {                
        var xml = new XElement("smil",
            new XElement("body",
                new XElement("seq",
                    items.Select(c => new XElement("media", 
                                       new XAttribute(
                                           "src",
                                           String.Format("http:\\\\www..mysite.com\\songs\\{0}", c)))))));
    
        xml.Save(xw);
    }
    

    Output:

    <smil>
      <body>
        <seq>
          <media src="http:\\www..mysite.com\songs\song1.mp3" />
          <media src="http:\\www..mysite.com\songs\song2.mp3" />
          <media src="http:\\www..mysite.com\songs\song3.mp3" />
        </seq>
      </body>
    </smil>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xml file and I am loading it in DataTable using DataSet.ReadXML.
Two Windows processes have memory mapped the same shared file. If the file consists
Ignoring unsafe code, .NET cannot have memory leaks. I've read this endlessly from many
I have a DataTable in memory that I need to dump straight into a
I have a large amount of data stored in an XML file, 173 MB
Suppose I have a small database represented in memory as a DataTable, what is
I'd like to use a memory profiler to determine if I have memory links
We have an in memory DataTable in a CLR procedure. After significant processing the
I have memory leak on jsonParser. Here is my code - (id) objectWithUrl:(NSURL *)url
I have memory problems with the webapp responsible from parsing XML event and pushing

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.