Solved

Playing with HTML Parser ?

Posted on 2000-03-13
6
191 Views
Last Modified: 2008-02-01
Hi !
does anybody have an exemple code using Java parser
to replace Balise <FoNT  cOLor=#000000  >  stuff </foNT>
by a balise<select name="select"> toto </select> ?

thanks
see ya !
0
Comment
Question by:NextOne
6 Comments
 
LVL 4

Expert Comment

by:jerch
ID: 2611603
import java.io.*;

class ReplaceTest {

    public static void main(String[] args) throws Exception {
        String wordToReplace = "replace";
        String newWord = "new";
       
        FileInputStream fis = new FileInputStream("yourfile.html");
        InputStreamReader isr = new InputStreamReader(fis);

        char[] buf = new char[1024];
        StringBuffer sb = new StringBuffer();

        while (isr.read(buf, 0, buf.length) != -1) {
            sb.append(buf);
        }

        int index = 0;
        String temp = sb.toString();

        while ((index = temp.indexOf(wordToReplace)) != -1) {
            sb.replace(index, wordToReplace.length(), newWord);
        }

       
    }
}
0
 
LVL 2

Expert Comment

by:muraliram
ID: 2612222
Dear Nextone,

Go and play with

javax.swing.text.html.parser.DocumentParser

This will ease your task.

Try..
all the best

Bye

Murali
0
 

Author Comment

by:NextOne
ID: 2613117
Adjusted points to 65
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:NextOne
ID: 2613118
For jerch :

Sorry I don't want to replace a Word ! I want
to Parse an HTML file there's lot's of different case
that coul match and I need to build a tree like the HTML Parser do. And i need to be realy sure to be in the right tag.

thanks

For Murali :

Thanks that's what i'm looking for but when I'm trying to use HTML Parser CallBack, I can't do what i wanted to do. I 'm looking for a tutorial or an exemple that help me...

I'm going to look at Document Parser but i think i ll have no more answer

If you have any good site or exemple ?

thanks !
0
 

Accepted Solution

by:
kbeier earned 65 total points
ID: 2622528
Hi NextOne,

Would a really good Java Regular Expression package help you?  My favourite is Package COM.stevesoft.pat.  You can get it at:

http://www.javaregex.com/

There are other good regex packages out there too though.  Maybe anyone else reading this could post another recommendation!

Hope this helps you.
0
 

Author Comment

by:NextOne
ID: 2622690
Thanks,
I'm going to look....
I found  a package that already help
me I can't give you the adress because I don't find it on the web but if some one is interested mail me !

 The package works has a streamTokenizer with html and it is very cool

for keier :

I gonna look at you link and tell you if it would match.... but i think i'll give you point

thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet  URL Rewriting 1 42
factorial example 4 47
fibonacci ten numbers 4 45
java jdbc batch example 8 40
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question