By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,289 Members | 3,049 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,289 IT Pros & Developers. It's quick & easy.

Clarification to replace the & symbol to & in xml using XSL

P: 5
Hi all,

Here, a xml file is not in proper format. I need to replace the "&" symbol to "&" under the attributes. Find below the sample xml file for glance:

<child2 attribute1="test&test">Testing</child2>

Let me know how to resolve this instance. I need output like -- attribute1="test&amp;test" --. I need to replace "&" symbol using the XSL.

Nov 3 '08 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 8,639
if your parser doesn't complain on the xml you can use the translate() function. but a correct working parser should give you an "undefined entity" error. in this case you have to change the & either by hand or by a script. maybe you can do something with CDATA, but I haven't used it like that yet.

Nov 3 '08 #2

Expert 100+
P: 2,057
I'd use a quick search/replace eg:
Expand|Select|Wrap|Line Numbers
  1. sed -e "s/\&/&amp;/g" a.txt > a.txt
You can't use xsl that effectively with this file since it isn't really xml.
Nov 3 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.