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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:48:57+00:00 2026-05-14T21:48:57+00:00

I have the following XML: <FootNotes> <Line id=10306 reference=*></Line> <Line id=10308 reference=**></Line> <Line id=10309

  • 0

I have the following XML:

<FootNotes>
  <Line id="10306" reference="*"></Line>
  <Line id="10308" reference="**"></Line>
  <Line id="10309" reference="***"></Line>
  <Line id="10310" reference="****"></Line>
  <Line id="10311" reference="+"></Line>
</FootNotes>

and I have the following code where I’m to get a Dictionary<int, string>() object into

myObject.FootNotes 

so that each Line is a Key/Value pair

var doc = XElement.Parse(xmlString);

var myObject = new
  {
      FootNotes = (from fn in doc
                       .Elements("FootNotes")
                       .Elements("Line")
                       .ToDictionary
                       (
                       column => (int) column.Attribute("id"),
                       column => (string) column.Attribute("reference")
                       )
                  )
  };

I am unsure how to get this from the XML into the object though. Can anyone suggest a solution?

  • 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-14T21:48:57+00:00Added an answer on May 14, 2026 at 9:48 pm

    Your code is nearly correct. Try this slight variation instead:

    FootNotes = (from fn in doc.Elements("FootNotes")
                               .Elements("Line")
                 select fn).ToDictionary(
                     column => (int)column.Attribute("id"),
                     column => (string)column.Attribute("reference")
                 )
    

    I don’t think the long from ... select syntax really helps much here. I’d use this slightly simpler code instead:

    Footnotes = doc.Descendants("Line").ToDictionary(
                    e => (int)e.Attribute("id"),
                    e => (string)e.Attribute("reference")
                )
    

    However you are using an anonymous type in your example code. You need to use a concrete type if you are planning to return this object to the caller.

    var myObject = new SomeConcreteType
        {
            Footnotes = ....
        };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Learning xml, Can anyone help me? I have following XML code: **<book lang=en>name of
I have the following XML file. I want to get Max(NR) using LINQ .
I have following xml which same child element (Filed) and I want to get
I have the following XML retreived from webservices.How do i get the value of
I have following XML code <?xml version=1.0 encoding=windows-1250?> <menu> <item> <id>0</id> <name>Pizzerie u soudu</name>
I have following xml file: <table name=countries> <column name=id>1</column> <column name=name>Abkhazia</column> <column name=code>XZ</column> <column
I have the following XML code: <CampaignFrameResponse xmlns=http://Qsurv/api xmlns:i=http://www.w3.org/2001/XMLSchema-instance> <Message>Success</Message> <Status>Success</Status> <FrameHeight>308</FrameHeight> <FrameUrl>http://delivery.usurv.com?Key=a5018c85-222a-4444-a0ca-b85c42f3757d&amp;ReturnUrl=http%3a%2f%2flocalhost%3a8080%2feveningstar%2fhome</FrameUrl> </CampaignFrameResponse>
I have following xml and I want to fetch the value of node which
I have following XML, and i wish to save its data in my SQL
I have following XML. I was able to remove all namespaces but not able

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.