i have a XML file that should be loaded on ASP MVC, i got the data from my Service, but failed parsing, idk why but the data can't go through List. Here my code
XML File
<ArrayOfNews xmlns="http://schemas.datacontract.org/2004/07/DIESWCF" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<News>
<CompID>70101</CompID>
<Descriptions>as the winner of awards</Descriptions>
<ImgPath>Company/UI.png</ImgPath>
<Title>University of Indonesia Animate Version</Title>
</News>
</ArrayOfNews>
Models
public class News
{
private int _compid;
private string _title, _desc, _img;
public int CompID
{
get { return _compid; }
set { _compid = value; }
}
public string Title
{
get { return _title; }
set { _title = value; }
}
public string Descriptions
{
get { return _desc; }
set { _desc = value; }
}
public string ImgPath
{
get { return _img; }
set { _img = value; }
}
}
Process
public List<News> GetViewNews()
{
List<News> newslist = new List<News>();
XmlDocument doc = new XmlDocument();
doc.Load(SU.URLService() + "ViewNews");
foreach (XmlNode feed in doc.SelectNodes("/ArrayOfNews/News"))
{
newslist.Add(new News
{
CompID = Convert.ToInt32(feed["CompID"].InnerText),
Title = feed["Title"].InnerText,
ImgPath = feed["http://localhost:54654/" + "ImgPath"].InnerText,
Descriptions = feed["Descriptions"].InnerText
});
}
return newslist;
}
When i try to breakpoints on doc
line, i got the data but however the return always gives 0 count. Any Idea?