Solved

Playing with HTML Parser ?

Posted on 2000-03-13
6
192 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Way to decrease size of apk file 9 104
Android development question 2 75
Facing this issue for maven proxy setting 2 26
printf performancy 11 83
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

713 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