my XQuery worked perferctly, but I've always used exact match, like:
concat(' and title ="',$title,'"')
However, this is not going to work in real world, since we need to change the exact match to contain.
In this case, t开发者_开发技巧he title is an XML element, $title is the variable defined in the XQuery, what we want is to do not just use equal sign but test whether the title contains the substring $title.
I've played around with the syntax but still failed, could anyone help me on getting the right syntax for changing the "=" to the contains?
Thanks in advance.
Use:
concat(' and title[contains(.,"', $title, '")]')
and title = $title
should become
and contains(title, $title)
But I don't understand really what you're trying to do with concat. Are you trying to generate an XQuery expression using XQuery? In that case you could change
concat(' and title = "', $title, '"')
to
concat(' and contains(title, "', $title, '")')
精彩评论