i am trying to get the tags that have an attribute that end with a certain id.
like
i want to get
Date: Jan 6th 2016
For any one reading this answer, these are the Xpath String functions supported in latest .Net 4.6 framework:
concat: Returns the concatenation of the arguments.
contains: Returns true if the first argument string contains the second argument string; otherwise returns false.
normalize-space: Returns the argument string with the white space stripped.
starts-with: Returns true if the first argument string starts with the second argument string; otherwise returns false.
string: Converts an object to a string.
string-length: Returns the number of characters in the string.
substring: Returns the substring of the first argument starting at the position specified in the second argument and the length specified in the third argument.
substring-after: Returns the substring of the first argument string that follows the first occurrence of the second argument string in the first argument string.
substring-before: Returns the substring of the first argument string that precedes the first occurrence of the second argument string in the first argument string.
translate: Returns the first argument string with occurrences of characters in the second argument string replaced by the character at the corresponding position in the third argument string.
MSDN Source
The function ends-with() is not defined for XPath 1.0 but only for XPath 2.0 and XQuery.
You are using .NET. .NET at this date does not implement XPath 2.0, XSLT 2.0 or XQuery.
One can easily construct an XPath 1.0 expression, the evaluation of which produces the same result as the function ends-with()
:
$str2 = substring($str1, string-length($str1)- string-length($str2) +1)
produces the same boolean result (true()
or false()
) as:
ends-with($str1, $str2)
In your concrete case you just need to substitute the right expressions for $str1
and $str2
. They are, accordingly, /myXml/data
and 'World'
.
So, the XPath 1.0 expression to use, that is equivalent to the XPath 2.0 expression ends-with(/myXml/data, 'World')
is:
'World' =
substring(/myXml/data,
string-length(/myXml/data) - string-length('World') +1
)
contains() and starts-with() are in XSLT1; ends-with() is in XSLT2 only.