Skip to Content
author's profile photo Former Member
Former Member

rendering xml iviews in java

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



Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Feb 22, 2004 at 02:30 PM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 23, 2004 at 11:11 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.