please help me


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: please help me

  1. #1
    Join Date
    Oct 2006
    Posts
    28

    please help me

    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;

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    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"?

  3. #3
    Join Date
    Oct 2006
    Posts
    28
    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

  4. #4
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    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.

  5. #5
    Join Date
    Oct 2006
    Posts
    28
    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>...
    Last edited by loveme; 10-24-2006 at 09:02 AM.

  6. #6
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    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.

  7. #7
    Join Date
    Oct 2006
    Posts
    28
    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....

  8. #8
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    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"+START8_TAG);
         System.out.println("start position"+start7Pos);
    
         start7Pos += START8_TAG.length();
    
         System.out.println("end tag"+END8_TAG);
    
         end7Pos = line.indexOf(END8_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;
         
         mark = end7Pos + END8_TAG.length();
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center