gpt4 book ai didi

c# - XPath matches() 在 C# 中使用正则表达式

转载 作者:行者123 更新时间:2023-12-03 16:03:29 25 4
gpt4 key购买 nike

更新:我在 - Adding XPath 2.0 functionality and variables to .NET XPath 上写下了我所做的事情,包括源代码和需要注意的事项。 (我的博客)。

对于 .NET 中的 XPath 语句,有没有办法将正则表达式传递给 matches()?

示例:执行

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

最佳答案

XPath 2.0 支持匹配功能。但是,.Net 实现了 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/

关于c# - XPath matches() 在 C# 中使用正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6447476/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com