XML with LINQ without XPath
I have an object structure I have deserialized from XML - but I'm wanting to use开发者_高级运维 it with LINQ. Is there any way I can add this capability to a normal object structure without the hassle of XPath stuff?
If it's already deserialized, you can just use linq to objects. Otherwise you can use linq to xml, which is slightly more friendly than XPath.
Sure. There is no special requirements on the XML for linq to XML, you can easily use your serialised XML, simply use the classes from system.xml.linq
In particular XElement / XDocument.
i.e.
XElement xe = XElement.Parse(**yourXML**);
from x in xe.Descendants("someElement")
select .....
精彩评论