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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:45:58+00:00 2026-05-28T01:45:58+00:00

I am receiving an xml message like the below (Believe me this is NOT

  • 0

I am receiving an xml message like the below (Believe me this is NOT how I want it):

<items>
 <item item="A" position="0">
   <itemvalue>10</itemvalue>
 </item>
  <item item="A" position="1">
    <itemvalue>20</itemvalue>
 </item>
  <item item="A" position="2">
    <itemvalue>30</itemvalue>
 </item>
  <item item="B" position="0">
    <itemvalue>10</itemvalue>
  </item>
   <item item="B" position="1">
     <itemvalue>20</itemvalue>
  </item>
   <item item="B" position="2">
     <itemvalue>30</itemvalue>
 </item>
</items>

I am shredding the XML using LINQ. So what I get is a List of Item | Position | Value. How I really want the data is to match my table structure.

Item  | Column1 | Column2 | Column3
A         10        20        30

What is the best way for me to take that List and Build a separate Object I can pass to the DB. Right now I am getting the distinct list of Items (So A & B here) and then passing that into a Lambda expression so that I can say give me the value where Item = A and Position = X (0,1,2).

Just wondering what the best method would be to “flatten” this poorly structured XML.

  • 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-28T01:45:59+00:00Added an answer on May 28, 2026 at 1:45 am

    Read xml and group on item attribute.

    var result = from ele in doc.Descendants("item")
                 group ele by ele.Attribute("item").Value into grp
                select grp;
    foreach (var   t in result)
     {
      XElement[] ar = t.ToArray();
      Console.WriteLine(t.Key + " "+ ar[0].Value  + " " + ar[1].Value + " " + ar[2].Value    );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are receiving an XML file from our client. I want to load the
A little help needed. I'm receiving an xml file similar to this: <?xml version=1.0
I am receiving XML strings over a socket, and would like to convert these
I'm receiving an XML message with unknown variable name elements... that is, they are
I am currently using this page http://www.silverlightshow.net/items/Silvester-A-Silverlight-Twitter-Widget.aspx to make a Silverlight application that gets
I am working on a small project that is receiving XML data in string
I am receiving dynamic xml where I won't know the attribute names, if you'll
When receiving a bug report or an it-doesnt-work message one of my initials questions
I am currently receiving this error: Validation of viewstate MAC failed. If this application
I have a scenario where we are receiving in xml messages. I need to

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.