on 07-29-2014 7:27 PM
Hi SAP PI Team,
I am working on SAp PI 7.31 single stack .
I have a requirement to convert the special character into entity reference as seen below.
Name | Character | Entity Ref |
Quotation mark | “ | "e; |
Ampersand | & | & |
Apostrophe | ‘ | ' |
Less than sign | < | ⁢ |
Greater than sign | > | > |
Could you please check and let me know if i will have to parse the entire xml or is there any other way to achieve this.
Regards
Ravi
Hi,
If you want to remove only single special character / only 5 characters as you listed use "Replace string" function.
If you want to remove multiple special characters use below UDF.
String result = "";
String[] splt;
delimiter = "'"; //special character to be removed
splt = input.split(delimiter);
for(int i =0; i < splt.length ; i++)
result = result + splt(i);
Regards,
Neelima.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you describe the whole scenario?
Why you want to replace the characters and how should the output look like?
When you replace < and > with entity reference, then the output is no valid XML, is this what you expect?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ravi,
We usually create a Java mapping and parse the input payload for handling the special characters.
You might want to use the SAX parser, see link below:
XML parsing using SaxParser with complete code | Java Code Geeks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ravi,
Can you view these characters in IE properly? If yes, then it means they are already escaped. Right-click on the payload and select view source you will see that " is really "e; in notepad.
If you want to convert everything in the XML to its entity ref, you have to parse it though.
Regards,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.