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

  • Home
  • SEARCH
  • 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 1038521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:59:08+00:00 2026-05-16T14:59:08+00:00

This code XmlDataDocument xmlDataDocument = new XmlDataDocument(ds); does not work for me, because the

  • 0

This code

XmlDataDocument xmlDataDocument = new XmlDataDocument(ds);

does not work for me, because the node names are derived from the columns’ encoded ColumnName property and will look like “last_x20_name”, for instance. This I cannot use in the resulting Excel spreadsheet. In order to treat the column names to make them something more friendly, I need to generate the XML myself.

I like LINQ to XML, and one of the responses to this question contained the following snippets:

XDocument doc = new XDocument(new XDeclaration("1.0","UTF-8","yes"), 
new XElement("products", from p in collection 
 select new XElement("product", 
     new XAttribute("guid", p.ProductId),  
     new XAttribute("title", p.Title), 
     new XAttribute("version", p.Version)))); 

The entire goal is to dynamically derive the column names from the dataset, so hardcoding them is not an option. Can this be done with Linq and without making the code much longer?

  • 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-05-16T14:59:09+00:00Added an answer on May 16, 2026 at 2:59 pm

    I appreciate the answers, but I had to abandon this approach altogether. I did manage to produce the XML that I wanted (albeit not with Linq), but of course there is a reason why the default implementation of the XmlDataDocument constructor uses the EncodedColumnName – namely that special characters are not allowed in element names in XML. But since I wanted to use the XML to convert what used to be a simple CSV file to the XML Spreadsheet format using XSLT (customer complains about losing leading 0’s in ZIP codes etc when loading the original CSV into Excel), I had to look into ways that preserve the data in Excel.

    But the ultimate goal of this is to produce a CSV file for upload to the payroll processor, and they mandate the column names to be something that is not XML-compliant (e.g. “File #”). The data is reviewed by humans before the upload, and they use Excel.

    I resorted to hard-coding the column names in the XSLT after all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 521k
  • Answers 521k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Almost the entire string module has been moved to the… May 16, 2026 at 9:06 pm
  • Editorial Team
    Editorial Team added an answer I know that you're not interested in going for full… May 16, 2026 at 9:06 pm
  • Editorial Team
    Editorial Team added an answer That should work. Did you try it? If it doesn't… May 16, 2026 at 9:06 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

This code doesn't work: URL url = new URL( xmlPath ); InputSource input =
This code is from Prototype.js . I've looked at probably 20 different tutorials, and
this code always returns 0 in PHP 5.2.5 for microseconds: <?php $dt = new
This code doesn't work: var number = $(this).find('.number').text(); var current = 600; if (current
This code and problem must be familiar, but I have not found anything. Any
This code in JS gives me a popup saying i think null is a
This code is works fine when you type 22 and 56 for example, it
This code compiles and works as expected (it throws at runtime, but never mind):
This code $html->link( &raquo;, '/events/view/'.$event['Event']['id']), array('escape'=>false,'class'=>'more') ) Outputs <a href=/events/view/4> &amp;raquo;</a> instead of >>
this code allows you to unzip file and create a folder in documents lets

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.