开发者

In XPath how can I check if a list contains a specific item?

开发者 https://www.devze.com 2023-03-28 17:15 出处:网络
I need to have a list contains function in xpath which will work like this: //*[contains( (\"one\", \"two\", \"three\"), \"one\")

I need to have a list contains function in xpath which will work like this:

//*[contains( ("one", "two", "three"), "one")

Is there anything like this?

Just for context, this is the problem I am trying to solve:

I have got a DOM tree

<element blah="one two three">

<element blah="bone two th开发者_如何学Goree">

<element blah="two three one">

I want to select the first and third because they cone contain one.

//*[contains(tokenize(@blah,'\s+'),'one')]

This is what I have so far, but it doesn't seem to be a valid XPath query.

I know that tokenize returns something in this format:

("one", "two", "three")

What I need is to be able to check what is in that list.


Simple:

"one" = ("one", "two", "three")

Or the more lengthy:

some $i in ("one", "two", "three") satisfies $i eq "one"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号