Purpose
Purpose of this web log is to give a solution to the above mentioned title and also this is a frequently occurring question in SDN XI forum.
Introduction
This is a frequently occurring question these days in SDN XI forums, How to append a carriage return after some place and after end of tag of xml or some string. So I tried to give solution in generic way b y writing a simple UDF.
Here is the input structure I am using and treating this as and input to the UDF as xmlString.
Output we want
Jani
Reminder
Don't forget me this weekend!
UDF for this
public String AddNewLineinEndofXMLTag(String xmlString,Container container){
//write your code here
String res = "";
int flag = 0;
for(int i = 0;i
{
if(xmlString.charAt =='<')
{
flag = 1;
res = res + xmlString.charAt ;
}
else
{
if(xmlString.charAt =='>')
{
flag = 0;
res = res +xmlString.charAt + "\n";
}
else
{
res = res +xmlString.charAt ;
}
}
}
return res;
}
I hope, it will help many people to solve their purpose. You can also customized it and use it with some other requirements as well as with similar kind of scenarios.