How to parser this xml content.
<Content>
<caption> Today Headline </caption>
<s1>
<name>6</name>
<name>4</name>
<name>4</name>
</s1>
<s2>
<name>3</name>
<name>6</name>
<name>0</name>
</s2>
</Content>
Mycode:
date = (from story
in xmlParser.Descendants("s1")
select new EspnViewModel
{
Category = story.Element("name").Value,
}).ToList();
return data;
I’m having a hard time trying to figure out how to parse everything out.
Why dont you use xmlParser.Descendants(“name”) instead?
EDIT:
var caption = xmlParser.Descendants(“caption”).First().InnerText;
var names = from story in xmlParser.Descendants(“name”)
select new EspnViewModel
{
Category = story.InnerText
}).ToList();
Note: I am writing this in haste, but you get the idea..