XDocument.Descendants not returning descendants

前端 未结 4 1684
暗喜
暗喜 2020-12-17 07:41



        
4条回答
  •  生来不讨喜
    2020-12-17 08:18

    It is correct that you have to include the namespace, but the samples above do not work unless you put the namespace in curly braces:

    XNameSpace ns = "http://www.lge.com/ddc";
    
    foreach (XElement element in xdoc.Descendants("{" + ns + "}nationalList")
    {
          MessageBox.Show(element.ToString());
    }
    

    Greetings Christian

提交回复
热议问题