Solved

Playing with HTML Parser ?

Posted on 2000-03-13
6
187 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Image decoding from Camera 3 72
JUnit 4 @Before and @BeforeClass differences 3 48
replace a word with other 1 40
couple of eclipse 5 25
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

920 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

15 Experts available now in Live!

Get 1:1 Help Now