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

  • Home
  • SEARCH
  • 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 7961547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:04:15+00:00 2026-06-04T05:04:15+00:00

I am new to C#, MVC4, ASP.NET, Entity Framework. I have an XML file

  • 0

I am new to C#, MVC4, ASP.NET, Entity Framework.

I have an XML file which I want to convert to a c# object.

How do I do this?

To give an idea of what I would like to do with the XML file:
I wish to display certain parts of the xml file within a table in a view.
I wish to be able to select parts of the data and send to a database.

At present, I have…

        public ViewResult Index()
    {
        string url = "......";
        var xml = XDocument.Load(url);

        return View(xml);
    }

My view model is:
@model IEnumerable
But I get an error on run saying:

The model item passed into the dictionary is of type ‘System.Xml.Linq.XElement’, but this dictionary requires a model item of type ‘System.Collections.Generic.IEnumerable`1[System.Xml.Linq.XElement]’.

  • 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-04T05:04:18+00:00Added an answer on June 4, 2026 at 5:04 am

    There are a few different methods of dealing with XML in .NET. These include XML Serializer, which will turn an XML string into a properly designed object; using XPath, which allows you to designate by a series of node names the information you want; or using XmlReader, which allows you to read through and parse the XML.

    EDIT: Going with Xlinq, you’d want to pass as a model either XElement or IEnumerable<XElement> to the view

    @model XElement
    

    or

    @model IEnumerable<XElement>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In ASP.net MVC4 there's this 'new' concept of a web API for exposing CRUD
I'm researching the new ASP.NET MVC4 Web API framework. I'm running Visual Studio 2011
I installed the new ASP .Net MVC4 beta on my machine and have been
Environment In my solution I have three projects, they are: Web (Asp.net MVC4) Model
This is the situation: I have an ASP.NET MVC 4 application. When I run
I am new to asp.net MVC, using MVC4 at the moment, learning by tutorials
I get this error when running any new ASP.NET MVC 4 project: Compiler Error
I am using ASP.NET MVC4 with Entityframework. Does Entityframework supports new Time datatype of
I am currently working in ASP.NET MVC 4 while using the entity framework. I've
I am using the new MVC4 ASP.Net Web API system. I am calling my

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.