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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:12:09+00:00 2026-06-16T03:12:09+00:00

I tried but could not get it? Here is the xml file <Root> <Data>

  • 0

I tried but could not get it? Here is the xml file

<Root>
    <Data>
        <Keys>Key1, key2, key3, key4</Keys>
        <FirstRow>Key1row1, Key2Row1, Key3Row1, Key4Row1</FirstRow>
        <SecondRow>Key1Row2, Key2Row2, Key3Row2, Key4Row2</SecondRow>
        <ThirdRow>Key1Row3, Key2Row3, Key2Row3, Key2Row3</ThirdRow>
        and so on .........
    </Data>
</Root>

I need to use Linq to XML:-

    var data = from d in xDoc.Root.Element("Data")
                              select d;
    foreach(var d in data)
    {
        ...
    }

I like to have a M-d array mapping of comma separated keys value with is comma separated Rows values.

Key1      key2        key3       key4
Key1row1  key2Row1    Key3Row1   Key4Row1
....
  • 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-16T03:12:10+00:00Added an answer on June 16, 2026 at 3:12 am

    The row elements can be iterated (as done), but it’ll take string.Split (or a more advanced parser) to decompose the row values themselves. In the following example it is done in the RowTextToValues method.

    Here is a LINQPad example (run as “C# Program”) with some hints:

    IEnumerable<string> RowTextToValues (string v) {
        return v.Split(new [] {", "}, StringSplitOptions.None);
    }
    
    XDocument TestDoc() {
        return XDocument.Parse(@"
        <Root>
            <Data>
                <Keys>Key1, key2, key3, key4</Keys>
                <FirstRow>Key1row1, Key2Row1, Key3Row1, Key4Row1</FirstRow>
                <SecondRow>Key1Row2, Key2Row2, Key3Row2, Key4Row2</SecondRow>
                <ThirdRow>Key1Row3, Key2Row3, Key2Row3, Key2Row3</ThirdRow>
            </Data>
        </Root>");
    }
    
    void Main()
    {
        var dataNode = TestDoc().Root.Element("Data");
    
        // -> IEnumerable<XElement>
        var rows = dataNode.Elements();
    
        // -> IEnumerable<IEnumerable<string>>
        var res = rows
            .Select(r => RowTextToValues(r.Value));
    
        res.Dump();
    }
    

    Converting to an 2-dimensional array or handling more complex rules is left as an exercise.

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

Sidebar

Related Questions

I tried this, but could not get through:- code behind protected HtmlTableRow trComment; protected
I tried following the answer to this question , but could not get xsd.exe
I tried searching in google but could not find any useful answer, if(verifier.length() >
I tried to find the answer to this question but could not, to be
I've tried looking at similar problems, but could not easily find one that helped
Question says it all. I tried browsing through the latest tag but could not
A really simple question but I could not figure it out... I tried to
i have tried looking online but had no luck, How i could delete all
I search everywhere and tried everything I could, but I cannot make my second
I tried to 1) load an xml file using javascript as an object, say

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.