0

I'm attempting to use the tokenize method in a SelectNodes(" ") call, to filter some things out.

I have something along the lines of:

<nodes>
    <node colors="RED,BLUE,YELLOW"/>
</nodes>

And my xpath is as such:

nodes/node[not(empty(tokenize("GREEN,YELLOW,PURPLE", ",") intersect tokenize(@colors, ",")))]

Simply, I've got two comma delimited list, one as an attribute, and one as a "filter" for the attributes. I want to select all nodes where @colors contains, somewhere, one of the words inside of "GREEN,YELLOW,PURPLE".

I thought I had the solution for it with that XPath, but it seems either: A: I did something wrong, or B: The version of XML DOM document I am using does not support tokenize()

The XPath above, in a SelectNodes( ) call will throw up an error message, saying msxml3.dll: Unknown method.", then pointing to the tokenize() method.

I tried doing setProperty("SelectionLanguage", "XPath"), but that did not seem to solve the issue either.

Is there any way for me to perform an equivalent XPath selection, without resorting to a bunch of and contains(@colors, "GREEN") and contains(@colors, "YELLOW")...?

Serge
  • 1,974
  • 6
  • 21
  • 33
  • `empty`, `tokenize`, and `intersect` are all XPath 2.0 features, and MSXML only provides XPath 1.0. – JLRishe Jul 09 '13 at 05:15

1 Answers1

0

As JLRishe says, msxml does not support XPath 2.0.

Depending on the environment that you are in there is probably third-party software you can use that supports either XPath 2.0 or XQuery 1.0 (which is a superset of XPath 2.0).

Microsoft's XML software is getting very dated and there has been little new development for 10 years now. It's time to consider alternatives.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164