0

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>

}
2
Contributors
1
Reply
10
Views
2 Months
Discussion Span
Last Post by rproffitt
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.