xquery expression to return a link text only if it contains within it a specific string

Posted by Arvind on Stack Overflow See other posts from Stack Overflow or by Arvind
Published on 2012-06-27T21:12:25Z Indexed on 2012/06/27 21:15 UTC
Read the original article Hit count: 261

Filed under:
|

I want to extract some links from a XML document (links are in same format as on html pages).

Now for eg a link is "http://xyz.com/start/tyu/a.html" and another is "http://ert.com/tyu/b.html" while a third link is "http://asdf.com/ghjk/c.html"

From the above 3 links (which I have with me using a for clause in a FLWOR expression)...I want only the links which contain within them a string "tyu" to be selected-- I thought of using substring for this, but substring requires start and end positions to be specified- whereas in my scenario, I dont know at which position the desired string will be.

How do I do substring matching in such a scenario, i.e. where exact position for occurrence of substring, is not known? I can use XQuery 1.0 for this purpose.

Finally, I want to extract the link URL, as well as link text...

© Stack Overflow or respective owner

Related posts about Xml

Related posts about xquery