xpathnavigator

Implementing my own XPathNavigator in C#

可紊 提交于 2019-12-03 19:07:31
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,

Which is the best for performance wise: XPathNavigator with XPath vs Linq to Xml with query?

久未见 提交于 2019-12-03 16:12:40
I have an application in which I am using XPathNavigator to iterate nodes. It is working fine. But I want to know that if I use LINQ to Xml.... What benefits(Performance, maintainability) I will get? With XPath, LINQ to Xml what is the performance hit? I am using C#.net, VS 2010 and my .xml is mid size. Well, XPathNavigator will generally be faster than Linq to XML queries. But there's always 'but'. Linq to XML will definitely make your code more readable and maintainable. It's easier (at least for me) to read linq query then analyze XPath. Also - you will get intellisense when writing query

Get attribute values from matching XML nodes using XPath query

与世无争的帅哥 提交于 2019-12-03 11:47:46
This doesn't seem like it should be difficult, but I'm stuck currently. I'm trying to get the attribute values for a particular attribute from nodes that match a given XPath query string. Here's what I have so far: public static IEnumerable<string> GetAttributes(this XmlDocument xml, string xpathQuery, string attributeName) { var doc = new XPathDocument(new XmlNodeReader(xml)); XPathNavigator nav = doc.CreateNavigator(); XPathExpression expr = nav.Compile(xpathQuery); XPathNodeIterator iterator = nav.Select(expr); while (iterator.MoveNext()) { XPathNavigator curNav = iterator.Current; if

Parse XPath Expressions

巧了我就是萌 提交于 2019-11-30 14:13:20
I am trying to create a 'AET' (Abstract Expression Tree) for XPath (as I am writing a WYSIWYG XSL editor). I have been hitting my head against the wall with the XPath BNF for the past three to four hours. I have thought of another solution. I thought I could write a class that implements IXPathNavigable, which returns a XPathNavigator of my own when CreateNavigator is called. This XPathNavigator would always succeed on any method calls, and would keep track of those calls - e.g. we moved to the customers node and then the customer node. I could then use this information (hopefully) to create

Parse XPath Expressions

岁酱吖の 提交于 2019-11-29 21:09:26
问题 I am trying to create a 'AET' (Abstract Expression Tree) for XPath (as I am writing a WYSIWYG XSL editor). I have been hitting my head against the wall with the XPath BNF for the past three to four hours. I have thought of another solution. I thought I could write a class that implements IXPathNavigable, which returns a XPathNavigator of my own when CreateNavigator is called. This XPathNavigator would always succeed on any method calls, and would keep track of those calls - e.g. we moved to