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 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

Related Questions

This code is reading from mysql db tables and should return few names. But
This code works: $(contentDiv).fadeIn(slow); This does not: var elementName = 'contentDiv'; $(elementName).fadeIn(slow); No fade
This code does not compile. public class Diamond { public static void diamondOfAsterisks(String *
This code does not return the correct result: Pattern p=Pattern.compile(^[y]{1,4}$|^[m]{1,4}$|^[d]{1,4}$); String text1=yyyy; String text2=mmm;
This code does not seem to compile, I just need to write something to
This code example is from the APE official website: http://www.ape-project.org/ var client = new
This code is not pretty, but I want to print out the last generated
This code comes from: http://code.activestate.com/recipes/577090-file-encryption-using-stream-cipher/ import sys import random if len(sys.argv) != 4: print
This code won't compile because there is an illegal reference to a static field.
This code throws parse error, which I do not understand why. function t(){ return

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.