hi there..
I've wrote an iview which renders and iview just like the .net using sap's xml and I'm trying to get it working. I think the iView server is having some problems with characters but I'm not sure how to replace them without extensive code..
in .net I can simply do this:
temp = Replace(temp, "href=""", "target=""_new"" href=""")
but I'm thinking I cannot use string.replaceAll or string.replace because we must use sdk 1.3.1 instead of 1.4.. and I dont want to tokenize etc.. unless I have to. Is there an easy way to replace characters in a string so my xml will not have problems because when it renders through the iview server it says:
"Incorrect syntax was used in a comment."
I need to replace all odd characters and html encode the &, "," etc.. any advice?
see code:
// This program written by John Mittendorf
// as a template for the SAP XML iView parcer
//
// This program in particulat goes to http://www.chron.com (Houston Chronicle Newspaper)
// and dnloads the top stories form the web page
//
// This program opens a stream from a url and
// is used to then parse the url for content in
// a format that the SAP Portal can understand
import com.sapportals.portal.prt.component.*;
import java.io.*;
import java.net.*;
public class aportalparser extends AbstractPortalComponent
{
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
{
URL uRL;
InputStream incommingStream = null;
DataInputStream dis;
String buff="";
String incommingString;
String out;
String tweaked;
String subStr;
int Start=0;
int End=0;
int StartPos=0;
int EndPos = 0;
//Write xml for iView server.. note the escape char ..language="HyperRelational".. the "" for the ""
//See the portal iView dev docs for detail on the xml
response.write(
"");
//Code to nab the url data and put it into a stream
try {
uRL = new URL("http://www.chron.com");
incommingStream = uRL.openStream();
dis = new DataInputStream(new BufferedInputStream(incommingStream));
while ((incommingString = dis.readLine()) != null)
{
buff += incommingString; //reads one line at a time and concatenates
}
//tweak the buffer and thin it down between content search points
Start=(buff.indexOf("<!
TOP STORY2 VIGNETTE LIST
->", StartPos + 32));
End=(buff.indexOf("<!
OTHER NEWS
>", StartPos)+ 0);
tweaked=buff.substring(Start, End);
//start parsing.. page is nasty so the code is also...
//reset the string parse points for the tweaked buffer
StartPos = 0;
EndPos=0;
//start to search here.. we need to grap one before the loop
StartPos=(tweaked.indexOf("Cassius called", StartPos + 14));
//nab top article
StartPos = (tweaked.indexOf("");
}
}