Implementing my own XPathNavigator in C#

2019-03-30 07:01发布

问题:

I am looking for a C# example implementation of a class derived from Microsoft's XPathNavigator class. Can any one point me at such an article?

As you may (or may not) know, the XmlNavigator is designed to allow one to superimpose XPath navigation on most any data model.

I have implemented my derived XPathNavigator class and it works very well. Very well that is except for XPath expressions that search recursively, i.e. "//*".

I am pretty sure that I have a subtle bug in the Clone, MoveToFirstChild, or MoveTo overides and I thought it might help to look at another example if one exists.

Also, I am sure that I have seen magazine articles that discuss this. My searches have proved yielded nothing. Maybe someone remembers such an article.

回答1:

Look at this article by Aaron Skonnard:

"XPath Selections and Custom Functions, and More",

which provides an example of a class derived from XPathNavigator.



回答2:

A bug in your implementation or the MS one? If it's the MS one then you can use reflector to take a peek inside.