开发者

Linq to Xml Get last Element - .Net 3.5

开发者 https://www.devze.com 2023-03-03 13:26 出处:网络
I\'m trying to fetch the last element according to it\'s name. I know there is Last() method on .Net 4, but since I must work with .Net 3.5 how can I find it.

I'm trying to fetch the last element according to it's name.

I know there is Last() method on .Net 4, but since I must work with .Net 3.5 how can I find it.

Example: The xml used as log file. My method signatur开发者_开发知识库e: GetLast(XName xName), and returns the last element specified (ExecutionReport, Scenario, Function etc.) I would like to get this element in order to add element afterwards.

This is the Xml file:

Linq to Xml Get last Element - .Net 3.5


.Last() exists in .Net 3.5 too.

You can write parent.Elements("ChildName").Last().

0

精彩评论

暂无评论...
验证码 换一张
取 消