How to replace XML reserved special characters from a block of string?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2015 07:14 PM
I need some help. I am send a xml file with details field values which may have lot of special reserve characters. I am writing a script where I need to find and replace all the special characters that XML reserves. Ex:
Special Character Escape Sequence Purpose
& & Ampersand sign
' ' Single quote
" " Double quote
> > Greater than
< < Less than
I am writing and onChange() client script to change the description field to replace all the special character with appropriate decoded string.
var descr = g_form.getValue('description');
strReplace = descr;
strReplace = strReplace.replace(/&/g, '&amp;').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
g_form.setValue('u_hpsm_details',strReplace);
Can someone help me please? I am stuck... Thanks in advance.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
This is my string I am trying -
Every time we are trying to upload the BP we are getting the below "Error"
"Error message from SAP : Material AP-2X2-D607 is not defined , language EN"
Have 'attached' the screenshot for &reference.
"Please advise." - chikkamallaiah@gmail.com<mailto:nchikkamallaiah@gmail.com>
________________________________
reply from: nchikkamallaiah@gmail.com<mailto:nchikkamallaiah@gmail.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
This is the output I get with that code - For very odd reason only 3rd line gets converted only rest does not.
Every time we are trying to upload the BP we are getting the below "Error"
"Error message from SAP : Material AP-2X2-D607 is not defined , language EN"
Have 'attached' the screenshot for &reference.
"Please advise." - chikkamallaiah@gmail.com<mailto:nchikkamallaiah@gmail.com>
________________________________
reply from: nchikkamallaiah@gmail.com<mailto:nchikkamallaiah@gmail.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2018 11:07 PM
Did you get this resolved? It appears your code is not showing all the syntax. Maybe thats the problem, maybe it was an issue when posting. In anycase I'm curious.