XML File :http://goalserve.com/samples/soccer_inplay.xml
Model:

[XmlRoot(ElementName = "localteam")]
public class Localteam
{
    [XmlAttribute(AttributeName = "name")]
    public string Name { get; set; }
    [XmlAttribute(AttributeName = "goals")]
    public string Goals { get; set; }
    [XmlAttribute(AttributeName = "id")]
    public string Id { get; set; }
}

Controller:

XmlDocument doc = new XmlDocument();

        List<Localteam> s = new List<Localteam>();

        doc.Load(Server.MapPath("soccer_inplay.xml"));

        foreach (XmlNode node in doc.SelectNodes("/scores/category/"))

        {

            s.Add(new Localteam

            {

                Name = node["Name"].InnerText

            });

        }

        return View(s);

View:

<tr>

    <th>Name</th>

    <th>Goals</th>

</tr>

@foreach (WebApplication22.Models.Localteam s in Model)

{
    <tr>

        <td>@s.Name</td>

        <td>@s.Goals</td>

    </tr>

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.