Solved

Playing with HTML Parser ?

Posted on 2000-03-13
6
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
printf performancy 11 105
Eclipse neon2 "Java build path" correctness 7 44
Setup Eclipse for Andriod development 2 20
How to access inner class in java (android)?? 12 13
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 …
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.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

751 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