Change character in XML

Hi Guys,

I have XML file which contain is like this :

 
<href>
mailto:?body=Content%20Link%20:%20http://localhost:8080/name1 name2.txt
</href>

Open in new window


Could we have string function in XML, to replace space character?

I need to replace the space between "name1" and the "name2" with character : %20.

So it will become like this :
mailto:?body=Content%20Link%20:%20http://localhost:8080/name1%20name2.txt

Please help. Thanks.
softblessAsked:
Who is Participating?
 
Ivo StoykovCommented:
Hi

There is function replace()  in XSLT (look here) but if you're not anchored to XML it will be easier to use 1 row JavaScript replace to do this task.

For XPath sample look here

HTH

Ivo Stoykov
var x = "<href>mailto:?body=Content%20Link%20:%20http://localhost:8080/name1 name2.txt</href>";
var a = x.replace(/\s/g, '%20');

Open in new window

0
 
softblessAuthor Commented:
ok I'll try before ivostoykov

Thanks
0
 
softblessAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.