Solved

Playing with HTML Parser ?

Posted on 2000-03-13
6
184 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now