Showing results for 
Search instead for 
Did you mean: 

rendering xml iviews in java

Former Member
0 Kudos

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 (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.*;



public class aportalparser extends AbstractPortalComponent


public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)



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



//Code to nab the url data and put it into a stream

try {

uRL = new URL("");

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;


//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("");



Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

When bound to jdk1.3, a good and powerfull way to work with strings is a library for regular expressions, e.g.:

JDK1.4 already contains a regex library.

0 Kudos