0

我想在 Xpath 表达式中捕获条件。例如在如下表达式中:

loan:_applicant/base:_entity/person:_phones/base:SmartRefOfPhoneeJDvviUx[base:_entity/contact:_category/base:_underlyingValue='Personal' and base:_entity/contact:_isMobile/base:_underlyingValue!='true']/base:_entity

我想抓住:

base:_entity/contact:_category/base:_underlyingValue='Personal'

base:_entity/contact:_isMobile/base:_underlyingValue!='true'

运算符示例中的 Xpath 可以是

是否可以使用正则表达式获取条件?

4

2 回答 2

1

Xpath 谓词用方括号括起来,所以

string regex=@"\[.*\]";
string predicate=Regex.Match(input, regex).Value;//assuming there is a match
regex=@"\s(and|or)\s";
string[] conditions=Regex.Split(predicate, regex);
于 2013-02-27T08:30:27.100 回答
1

XPath 2.0 具有用于正则表达式匹配的函数,例如matches()、replace() 和tokenize()。这些在 XPath 1.0 中不可用。

于 2013-02-27T11:32:07.723 回答