From: Oleg T. <ol...@tk...> - 2006-05-25 20:10:10
|
Hmmm, you must be missing something. Here is a working sample: <foo xmlns:b="bar"> <b:bar>text</b:bar> </foo> XmlDocument doc = new XmlDocument(); doc.Load("../../XMLFile1.xml"); string xpath = "/foo/b:bar"; XPathExpression expr = XPathExpression.Compile(xpath); ExsltContext ctx = new ExsltContext(doc.NameTable); ctx.AddNamespace("b", "bar"); expr.SetContext(ctx); Console.WriteLine(doc.CreateNavigator().SelectSingleNode(expr).OuterXml); -- Oleg Roy Cornelissen wrote: > Hi, > > I'm in the process of implementing the Mvp.Xml library into my project. > I'm having trouble precompiling xpath expressions that use namespace > prefixes. If I specify the namespace prefix in the xpath expression, I > get the exception "Namespace Manager or XsltContext needed. This query > has a prefix, variable, or user-defined function.". If I leave out the > prefix, the expression does not return the nodes I expect, so I do need > to specify a namespace in my xpath query. > > Am I overlooking something? > > Thanks! > > Regards, Roy Cornelissen > > _________________________________________________________________ > Hotmail en Messenger on the move http://www.msn.nl/services > > > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > mvp-xml-help mailing list > mvp...@li... > https://lists.sourceforge.net/lists/listinfo/mvp-xml-help |