XDocument.Element returns null when parsing an xml string

后端 未结 4 2033
悲哀的现实
悲哀的现实 2021-01-18 09:43

I have this xml string:



        
4条回答
  •  情歌与酒
    2021-01-18 10:24

    var xDoc = XDocument.Load(filename);
    XNamespace ns = "http://schemas.zune.net/catalog/apps/2008/02";
    var prices = xDoc
                    .Descendants(ns + "offer")
                    .Select(o => (decimal)o.Element(ns + "price"))
                    .ToList();
    

提交回复
热议问题