Iam reading a following part of file and write to another file... iwant to handle this code.....as single line
<edm:code>update</edm:code></edm:OrderTransactionType><edm:despatchTime>2006-10-13T02:31:28Z</edm:despatchTime><edm:OrderTransactionResult><edm:code>PARTIAL_PASS</edm:code></edm:OrderTransactionResult><edm:Order>
from the above program....... iwant output PARTIAL_PASS.I use delimiter as<edm:code> but it takes only first occurence therfor i got output as update only.Can any body helpme wht changes done in abobve code.I only want to change existing code...not ready to use XML parser.please can any body help me....
START8_TAG="<edm:code>";
final string END8_TAG="</edm:code>";
if((logging)&&(line.indexOf("</edm:OrderTransactionResult>")>-1)) {
start7Pos= line.indexOf(START8_TAG);
start7Pos= START8_TAG.length();
System.out.println("index"+START8_TAG);
//start7Pos+= START8_TAG.length();
System.out.println("sstart position"+start7Pos);
System.out.println("end tag"+END8_TAG);
end7Pos = line.indexOf(END8_TAG);
// end7Pos = END8_TAG.length();
System.out.println("index"+ end7Pos);
System.out.println("end tag line "+ line);
System.out.println("line.substring"+line.substring(start7Pos,end7Pos));
efound11=true;
10-24-2006, 07:39 AM
nspils
You have not programmed your parser to continue until the end of the line. It's a one shot deal. How can you keep going on "line"?
10-24-2006, 07:42 AM
loveme
no yaar,i show the part of problem occured....
i uuse buffered reader to search for end of linei could not want all output like <edm:code>update</edm:code>.But iwant out put inside <edm:OrderTransactionResult>----
--------------------
</edm:OrderTransactionResult>
<<edm:OrderTransactionResult><edm:code>PARTIAL_PASS</edm:code></edm:OrderTransactionResult>
therfor i used following in code
if((logging)&&(line.indexOf("</edm:OrderTransactionResult>")>-1))
please help me....
my requirtement is as output as
PARTIAL_PASS
10-24-2006, 07:53 AM
nspils
Are you using the StringReader class? If so, you can use mark() and reset() to know where to be reading when you return. You can also use the String class's version of indexOf() which takes an index argument to indicate where the search should begin. Using the one-argument version starts the search over at the beginning of the string.
10-24-2006, 07:57 AM
loveme
Iam not using string reader.Iam using buffered reader and writer......Please look the above code iam wriiren and tell me what modification required.I alreday used indexof methoda but it only take first occurence.......Can u tell me it how it take in above criteria.iam search for <edm code>...
10-24-2006, 08:34 AM
nspils
The indexOf method you are using is the one argument version (just the sub-string you are searching for). Try using the two-argument method, the second being the "mark" of the location where you want to start your search. Initialize "mark" to be 0, so it will start at the beginning of the string. Update your "mark" to being the index after your current found substring.
Add a while test (before your if-test) to allow a loop while you are not at the end of your String.
10-25-2006, 12:57 AM
loveme
Canu u plaease explain with example......???
Ie PARTIAL_PASS is generated dynamically.....it may be change at next time like Failure or some otherword...can u please tell me wht iwill do in that case....
10-25-2006, 06:33 AM
nspils
I was suggesting a structure like this:
Code:
int mark = 0;
while( mark != line.length())
{
start7Pos= line.indexOf(START8_TAG, mark);
System.out.println("index"+ end7Pos);
System.out.println("end tag line "+ line);
System.out.println("line.substring"+line.substring(start7Pos,end7Pos));
efound11=true;