Check out XFiles... ["Using XPath to Navigate the File System"]
CodeProject - Using XPath to Navigate the File System
Introduction
This article has two goals:
- It shows how to make your own XPathNavigator implementation and use it to evaluate XPath expressions and apply XSLT transformation to the structures, not intended to be used this way
- It presents the new alternative way to work with files and folders that some people may consider useful
What is XPathNavigator
XPathNavigator
is the system abstract class, that implements XPath document model and provides means of navigating through XML nodes, and evaluating XPath expressions. UnlikeXmlNode
orXNode
,XPathNavigator
is a cursor, that may point to any node in the XML tree and be moved to another node.XPathNavigator
is also used as an input forXslCompiledTransform
, and therefore any implementation of theXPathNavigator
can be transformed with an XSLT stylesheet.
XPathNavigator
implementations exist for all XML models in .NET, includingXmlDocument
and LINQ to XML. Generally an instance of anXPathNavigator
inheritor can be created for classes that implementIXPathNavigable
interface. This interface contains a single method -CreateNavigator
. ClassesXmlNode
andXPathDocument
(a special fast model that only provides read-only access viaXPathNavigator
model) implementIXPathNavigable
. However this is not always the case. The newest library for working with XML - LINQ to XML - allows creation ofXPathNavigator
with extension methods.It's worth mentioning that none of the system-integrated implementations of the
XPathNavigator
are public.How to implement XPathNavigator
XPathNavigator
contains 116 public members, 112 of which can be overridden. Good news that only 20 of them are abstract, i.e. must be implemented.Here they are:
...
When I first saw this I wasn't sure if it was insane or inspired. I'm still not sure about that, but I am sure that I think this is pretty awesome.
1 comment:
Ha-ha, just googled for my article and came across you post. Thanks, Greg
Post a Comment