How to use the “translate” Xpath function on a node-set

后端 未结 3 857
离开以前
离开以前 2021-01-02 18:49

I have an XML document that contains items with dashes I\'d like to strip

e.g.


   
      a-         


        
3条回答
  •  [愿得一人]
    2021-01-02 19:08

    I know I can find-replace a single item using this xpath

    /xmldoc/items/item[1]/translate(text(),'-','')
    

    Which will return

    "abc"
    

    however, how do I do this for the entire set?

    This cannot be done with a single XPath 1.0 expression.

    Use the following XPath 2.0 expression to produce a sequence of strings, each being the result of the application of the translate() function on the string value of the corresponding node:

    /xmlDoc/items/item/translate(.,'-', '')
    

提交回复
热议问题