on 08-20-2012 3:41 PM
Hi gurus
we have an issue regarding newLines in CDATA like following example;
<comment><![CDATA[position-text
line 2 text line 2
line 3 no.: 870011 ]]></comment>
and need to remove the newlines so that we send everything in a single line.
<comment><![CDATA[position-text line 2 text line 2 line 3 no.: 870011 ]]></comment>
i tried with replace string and trim function without success.
can anyone help me?
Regards
PM
Hi Peter,
you can try this UDF. I tested this in my system, it was able to remove newlines and carriage returns from CDATA section.
public String removeNewline(String s,Container container){
try
{
String a="";
int l=s.length();
for(int i=0;i<l;++i)
{
if(s.charAt(i)=='\n' || s.charAt(i)=='\r')
{
continue;
}
a=a+s.charAt(i);
}
s=a;
}
catch(Exception e)
{
e.printStackTrace();
}
return s;
}
Alternatively you can use this code
public String removeNewline(String s,Container container){
try
{
s=s.replaceAll("\n", "");
s=s.replaceAll("\r","");
}
catch(Exception e)
{
e.printStackTrace();
}
return s;
}
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi. Peter.
You can try a simple sentence in your UDF.
Variable:var1
return var1.replace("\n", "");
Regards
Lucho.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.