匹配XPath()使用C#正则表达式 [英] XPath matches() using regular expressions in C#

查看:154
本文介绍了匹配XPath()使用C#正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:我写了我做什么,以源代码和看点,在 - 的添加的XPath 2.0功能和变量.NET的XPath (我的博客)。



有没有办法通过一个正则表达式来匹配()在.NET中XPath语句



例如:是否的

 /迎风的一室公寓/员工/雇员[匹配(字符串(姓氏),* A-b的XPath [12] C. *')]


解决方案

的XPath 2.0支持的匹配功能。然而,净实现的XPath 1.0。



您将需要添加一个自定义函数来实现匹配。请参见 http://msdn.microsoft.com/en-us/library/ms950806.aspx



它看起来像Mvp.Xml项目:EXSLT.NET模块实现了大部分的XPath 2.0;包括火柴。请参见 http://mvp-xml.sourceforge.net/exslt/


Update: I wrote up what I did, with source code and things to watch for, at - Adding XPath 2.0 functionality and variables to .NET XPath (my blog).

Is there a way to pass a regular expression to matches() for an XPath statement in .NET?

Example: do an xpath of

"/windward-studios/Employees/Employee[matches(string(LastName), '.*A?B[12]C.*')]"

解决方案

XPath 2.0 supports the matches function. However, .Net implements XPath 1.0.

You would need to add a custom function to implement match. See http://msdn.microsoft.com/en-us/library/ms950806.aspx

It looks like the Mvp.Xml Project: EXSLT.NET module implements most of XPath 2.0; including matches. See http://mvp-xml.sourceforge.net/exslt/

这篇关于匹配XPath()使用C#正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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