I’ve a xml document like this.
<Students>
<Student>
<Node Type="http://www.something.com/xyz/10/abc/RollNumber"
Value="Original=10000;Modified=100003445" />
<Node Type="http://www.something.com/xyz/10/abc/SerialNumber"
Value="Original=10000;Modified=172777" />
<Node Type="http://www.something.com/xyz/10/abc/Stream"
Value="Original=CS;Modified=EC" />
</Student>
</Students>
To get the value of the stream, I can write:
Select @MyXML.value('(/Students/Student/Node[@Type="http://www.something.com/xyz/10/abc/Stream"]/@Value)[1]', 'varchar(100)') AS ChangedValue
My problem is that the url part may change, hence I want to match it based on some criteria like
@Type = "%Stream"
or
@Type.Contains("Stream")
Is it possible?
The xpath engine in SQL supports the
containsfunction, so you can say:Unfortunately however, the obvious
ends-with()is an xpath 2.0 function, and the SQL engine doesn’t offer that, so if you wanted to test for the string ending withStreamyou’d have to say (as per this post):