Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.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# 获取XDocuments中元素的所有属性值_C#_Xml_Linq To Xml - Fatal编程技术网

C# 获取XDocuments中元素的所有属性值

C# 获取XDocuments中元素的所有属性值,c#,xml,linq-to-xml,C#,Xml,Linq To Xml,我想在XDocument e、 g 既然您已经确认xml中没有任何名称空间,那么就可以去掉xmlns,这样它就可以工作了 var urls = from vector in this.root.Descendants("ulink") select vector.Attribute("url").Value; 您是否获得了一个DoeSonorkException?此.root.subjects(xmlns+“ulink”)中的向量中的是否用于获取元素?没有例外,它只是

我想在
XDocument

e、 g


既然您已经确认xml中没有任何名称空间,那么就可以去掉
xmlns
,这样它就可以工作了

var urls = from vector in this.root.Descendants("ulink") 
           select  vector.Attribute("url").Value;

您是否获得了一个
DoeSonorkException
?此.root.subjects(xmlns+“ulink”)中的向量中的
是否用于获取元素?没有例外,它只是没有任何值。我刚刚尝试过,this.root.subjects(xmlns+“ulink”),但这都不返回值。在这种情况下,我认为您的名称空间可能有问题。也许是拼错了汉克斯,你可能是对的,我正试图将xmldocument解析为XDocument。而是使用xdocument。也许我应该继续使用xmldocument。
var urls = from vector in this.root.Descendants(xmlns + "ulink") 
           select  vector.Attribute("url").Value;
var urls = from vector in this.root.Descendants("ulink") 
           select  vector.Attribute("url").Value;