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


i have xml document contains items dashes i'd strip

e.g.

<xmldoc>    <items>       <item>a-b-c</item>       <item>c-d-e</item>    <items> </xmldoc> 

i know can find-replace single item using xpath

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

which return

"abc"

however, how do entire set?

this doesn't work

/xmldoc/items/item/translate(text(),'-','') 

nor

translate(/xmldoc/items/item/text(),'-','') 

is there way @ achieve that?

i know can find-replace single item using xpath

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

which return

"abc" 

however, how do entire set?

this cannot done single xpath 1.0 expression.

use following xpath 2.0 expression produce sequence of strings, each being result of application of translate() function on string value of corresponding node:

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

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -