Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在Windows phone中从Webservice获取列表?_C#_Xml_Linq_List_Service - Fatal编程技术网

C# 如何在Windows phone中从Webservice获取列表?

C# 如何在Windows phone中从Webservice获取列表?,c#,xml,linq,list,service,C#,Xml,Linq,List,Service,我有一个密码: List<Songs> song; ServiceBaiHat.MywebserviceSoapClient service = new ServiceBaiHat.MywebserviceSoapClient(); service.getListCatalogAsync(); service.getListCatalogCompleted+=service_getListCatalogCompleted; private void service_getLi

我有一个密码:

List<Songs> song;
ServiceBaiHat.MywebserviceSoapClient service = new ServiceBaiHat.MywebserviceSoapClient(); 
service.getListCatalogAsync();

service.getListCatalogCompleted+=service_getListCatalogCompleted;


private void service_getListCatalogCompleted(object sender, ServiceBaiHat.getListCatalogCompletedEventArgs e)
{
  if (e.Result != null)
  {
    XElement element = XElement.Parse(e.Result.ToString());
    listbaihat = (from p in element.Descendants("songs")
                  select new Songs
                  {
                    name = (string)p.Element("name"),
                    link = (string)p.Element("link"),
                    album = (string)p.Element("album")
                  }).ToList<Songs>();

  }
}
列表歌曲;
ServiceBaiHat.MywebserviceSoapClient服务=新的ServiceBaiHat.MywebserviceSoapClient();
service.getListCatalogAsync();
service.getListCatalogCompleted+=服务\u getListCatalogCompleted;
私有无效服务\u getListCatalogCompleted(对象发送方,ServiceBaiHat.getListCatalogCompletedEventArgs e)
{
如果(例如,结果!=null)
{
XElement元素=XElement.Parse(例如,Result.ToString());
listbaihat=(来自element.substands(“歌曲”)中的p)
选择新歌
{
名称=(字符串)p.Element(“名称”),
link=(字符串)p.Element(“link”),
相册=(字符串)p.Element(“相册”)
}).ToList();
}
}

现在,为什么element.subjections(“songs”)出现错误?

您可以发布XML吗?我不明白为什么歌曲类型被称为
songs
(复数),而
列表被称为
song
(单数)
listbaihat
不包含变量定义。。。您是否缺少
var
或它是否有类型?如果不知道您遇到的错误,可能是元素为null,也可能是没有“songs”子体。