XSL substring and indexOf

后端 未结 6 1144
说谎
说谎 2021-02-07 00:14

I\'m new to XSLT. I wonder if it is possible to select a substring of an item. I\'m trying to parse an RSS feed. The description value has more text than what I want to show. I\

6条回答
  •  清歌不尽
    2021-02-07 00:53

    I want to select the text of a string that is located after the occurrence of substring

    You could use:

    substring-after($string,$match)
    

    If you want a subtring of the above with some length then use:

    substring(substring-after($string,$match),1,$length)
    

    But problems begin if there is no ocurrence of the matching substring... So, if you want a substring with specific length located after the occurrence of a substring, or from the whole string if there is no match, you could use:

    substring(substring-after($string,substring-before($string,$match)),
              string-length($match) * contains($string,$match) + 1,
              $length) 
    

提交回复
热议问题