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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:49:46+00:00 2026-06-03T07:49:46+00:00

This is my first experience with LINQ to XML, so bear with me. I’m

  • 0

This is my first experience with LINQ to XML, so bear with me. I’m parsing a Web Services generated XML file for values to insert into SQL Server. The XML data looks like:

...
    <row>
        <value>912EOE01L0K0</value>
        <value>4369     </value>
        <value>PTO   </value>
        <value>PTO03 </value>
        <value>3 Days PTO     </value>
        <value>1</value>
        <value>0</value>
        <value>0</value>
        <value>1</value>
        <value>0</value>
        <value>0</value>
        <value>7.36</value>
        <value>0</value>
        <value>0</value>
    </row>
    <row>
        <value>912EOE01L0K0</value>
        <value>4369     </value>
        <value>SICK  </value>
        <value>SCK07 </value>
        <value>7 Sick Days    </value>
        <value>2.34</value>
        <value>0</value>
        <value>0</value>
        <value>2.34</value>
        <value>0</value>
        <value>0</value>
        <value>35.979999</value>
        <value>0</value>
        <value>0</value>
    </row>
...

The C# class that is doing the parsing needs to be dynamic to handle a variable number of rows and values within each row, though I do know how many values will be in each row once I start parsing. I want to group (pivot?) all of the values in a row into a single object, String and comma separated if possible. I know I could do this by pulling all of the values into a list, then iterating through them and grouping every X into a “row” object, where X is the number of values in each row but it feels like there should be a more LINQ-y way to do this. Is there a LINQ query that will for each row, group all of the values into a single object?

Thanks.

  • 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-03T07:49:47+00:00Added an answer on June 3, 2026 at 7:49 am

    This is a great application for Linq-to-Xml. Once you’ve got the XML loaded into an XDocument, you can write this:

    XDocument MyXDoc;
    // TODO, load or parse MyXDoc
    
    string[] CsvList = MyXDoc.Root.Elements("row")
        .Select(row => 
            String.Join(", ", row.Elements("value").Select(val => (string)val).ToArray() )
         )
        .ToArray();
    

    This will give you an array of each row with the values represented as a CSV string.

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

Sidebar

Related Questions

I'm developing a web system using regular PHP. This was my first experience with
This is my first experience with themes. I've created a skin file for a
This is my first experience with JDBCTemplates and I ran into a case where
This is my first experience with javascript, and... Well... Ugh. Here's what's happening: function
Code first: '''this is main structure of my program''' from twisted.web import http from
Guess people need some experience with Linq-to-xml and knowledge of the build of a
This is my first experience in programming with Python and I'm trying to log
I'm developing a game for android and this is my first experience with OpenGL.
I recently installed Microsoft Test Manager 2010 and this is my first experience with
This is my first experience with C# and part of my limited experience with

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.