I would like to enable XPath navigation over my POCOs (i.e. "plain old CLR objects"). From a brief search, I have found several options:
- Use ObjectXPathNavigator .NET 1.0 implementation. However, since it was written against .NET 1.0, I have concerns about potential issues with generics (and whatever else that wasn't supported back then).
- Implementing my own XPathNavigator by extending the .NET XPathNavigator class.
The second option appears to be what I want. However, I don't have the time to write my own -- especially since I expect that someone else has already implemented it and made it open source. I just have a difficult time finding this elusive PocoXPathNavigator开发者_运维问答 implementation!
Thanks.
The best approach, it seems, is to use ObjectXPathNavigator (option 1) since it's open source. I plan to extend it to support generics and whatever else I need.
You can serialize your objects as xml string into memory and then use the standard XPathNavigator to search in it. There are also some native XML database systems which you may use to serialize your objects into.
The question is, why do you need an XPathNavigator to search in objects? If you have a large objects graph you may consider using some kind of graph db / nosql db.
精彩评论