XPath和C# [英] xpath and c#

查看:210
本文介绍了XPath和C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个winform应用程序,通过一个XML文档搜索。
我搜索我需要的XML特性转换中的XPath条件下的情况下,通过使用小写()XPath函数。
这将导致相关的函数命名空间问题

I am trying to create a winform application that searches through an XML doc. for my search I need to convert the the XML attribute in the xpath condition to lower case, by using lower-case() xpath function. this causes a problem related to the function namespace.

我已尝试添加manualy命名空间:

I have tried to add the namespace manualy:

        XmlNamespaceManager nsMgr = new XmlNamespaceManager(prs.Doc.NameTable);
        nsMgr.AddNamespace("fn", "http://www.w3.org/2005/02/xpath-functions");
        XmlNodeList results = prs.Doc.SelectNodes("//function[starts-with(fn:lower-case(@name),'" + txtSearch.Text + "')]",nsMgr);



但我仍然得到异常:需要对这个查询,因为一个未知功能的
XsltContext

but still I get exception: XsltContext is needed for this query because of an unknown function.

推荐答案

FN:小写中的的XQuery 1.0和XPath 2.0 。 XSLT 2.0可XPATH 2.0。

fn:lower-case is defined in XQuery 1.0 and XPath 2.0. XSLT 2.0 works with XPATH 2.0.

据我所知,.NET一直不支持XPATH 2.0呢。从.NET中XSLT的版本是1.0,以及2.0不还。

AFAIK, .NET hasn't support XPATH 2.0 yet. and the XSLT version from .NET is 1.0 as well not 2.0 yet.

这篇关于XPath和C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆