Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.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
.net 如何根据元素的属性对元素进行排序';儿童_.net_Vb.net_Linq_Xelement - Fatal编程技术网

.net 如何根据元素的属性对元素进行排序';儿童

.net 如何根据元素的属性对元素进行排序';儿童,.net,vb.net,linq,xelement,.net,Vb.net,Linq,Xelement,对于一个像 <a> <b><c id="2"></b> <b><c id="3"></b> <b><c id="1"></b> </a> 有没有办法获取按id值排序的列表 我试过了,但没有成功 bElements.OrderBy(函数b作为XElement)b.Elements.Attributes(“id”)和bElements.OrderBy(函数b

对于一个像

<a>
 <b><c id="2"></b>
 <b><c id="3"></b>
 <b><c id="1"></b>
</a>

有没有办法获取按id值排序的
列表

我试过了,但没有成功


bElements.OrderBy(函数b作为XElement)b.Elements.Attributes(“id”)
bElements.OrderBy(函数b作为XElement)b.Elements.ToString)

根据您的具体需要,您可以执行以下操作:

bElements.OrderBy(function (b As XElement) b.Elements.Attributes("id").First().Value)
或者这个:

bElements.OrderBy(function (b As XElement) b.Elements.First().Attribute("id").Value)
甚至这个:

bElements.OrderBy(function (b As XElement) b.<c>.@id)
bElements.OrderBy(函数(b作为XElement)b..@id)