开发者

How to use OrderBy in Linq using xpath

I have开发者_如何学编程 2 IEnumerable<XPathNavigator> and I want to sort it by child value.

item1 = from XPathNavigator item in iterator1 select item;  
item2 = from XPathNavigator item in iterator2 select item;

item1 = item1.Union(item2);

item1.OrderBy(res => int.Parse(GetNavigatorValue(res, "./item[@value='ParentId']")));

static string GetNavigatorValue(XPathNavigator iterator, string xpath)
{

   XPathNodeIterator inner = iterator.Select(xpath);
   inner.MoveNext();
   return inner.Current.Value;
}

It doesn't work.

How do I use OrderBy in Linq if I need to sort it by xpath?

Thanks, user460397


Is that the problem? Shouldn't it be

item1 = item1.OrderBy( ... );

?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜