.net - Can I use an XPathExpression compiled from one navigator with a different navigator? -


if xpathnavigator, , use compile xpathexpression exp, constraints there on way can use exp? can use exp different navigator? know runs, , seems give correct results if compiling xpathnavigator formed doc or node different evaluating xpathnavigator. don't know if safe.

here's rudimentary example of mean. it's nonsensical illustrates point

private object testxpath(xmlnode n1, xmlnode n2) {   xpathnavigator nav1 = n1.createnavigator();   xpathexpression exp = nav1.compile("somexpath");    // evaluate using navigator compiled exp   object result = n1.evaluate(exp);   if (result == null)   {     xpathnavigator nav2 = n2.createnavigator();     // evaluate using navigator did not compile exp.  legal?     result = nav2.evaluate(exp);   }   return result; } 

you may freely use expression on other navigators. according daniel cazzulino, document create original navigator irrelevant, xpath expression compilation independent of document instance.
http://weblogs.asp.net/cazzu/archive/2003/10/07/30888.aspx


Comments