Thread: [Htmlparser-user] Rebuild HTML File
Brought to you by:
derrickoswald
From: Mark S. <htm...@ey...> - 2006-06-26 07:54:29
|
hi, is it possible to change certain stirngs in a html file, without "rebuilding" it? I would like to change some string in a html file, like a dictionary lookup, but i dont want to rebuild the html file like its done in URLModifyingVisitor. Can anybody give me a hint? I've still got Parser p = new Parser(); p.setInputHTML(html); SegmentReplacingVisitor s = new SegmentReplacingVisitor(); p.visitAllNodesWith(s); and do some text.setText() within the SegmentReplacingVisitor each time i visit a StringNode. How to save it into a translated.htm file without rebuilding it? thanks a lot |
From: Ian M. <ian...@gm...> - 2006-06-26 08:11:06
|
If you do Parser.parse() you get a NodeList, and then if you call the toHtml() method it will return a String of the reparsed code. Ian On 6/26/06, Mark Stark <htm...@ey...> wrote: > hi, > > is it possible to change certain stirngs in a html file, without > "rebuilding" it? I would like to change some string in a html file, like > a dictionary lookup, but i dont want to rebuild the html file like its > done in URLModifyingVisitor. > > Can anybody give me a hint? I've still got > > Parser p = new Parser(); > p.setInputHTML(html); > SegmentReplacingVisitor s = new SegmentReplacingVisitor(); > p.visitAllNodesWith(s); > > and do some text.setText() within the SegmentReplacingVisitor each time > i visit a StringNode. How to save it into a translated.htm file without > rebuilding it? > > thanks a lot > > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > |
From: Mark S. <htm...@ey...> - 2006-06-26 16:54:30
|
I dont understand. I've got a html file, manipulate some tags with my visitor, perhaps change an attribute value. and then? serialize the toHtml() output into a file and thats it? Ian Macfarlane schrieb: > If you do Parser.parse() you get a NodeList, and then if you call the > toHtml() method it will return a String of the reparsed code. > > Ian > > On 6/26/06, Mark Stark <htm...@ey...> wrote: >> hi, >> >> is it possible to change certain stirngs in a html file, without >> "rebuilding" it? I would like to change some string in a html file, like >> a dictionary lookup, but i dont want to rebuild the html file like its >> done in URLModifyingVisitor. >> >> Can anybody give me a hint? I've still got >> >> Parser p = new Parser(); >> p.setInputHTML(html); >> SegmentReplacingVisitor s = new SegmentReplacingVisitor(); >> p.visitAllNodesWith(s); >> >> and do some text.setText() within the SegmentReplacingVisitor each time >> i visit a StringNode. How to save it into a translated.htm file without >> rebuilding it? >> >> thanks a lot >> >> >> Using Tomcat but need to do more? Need to support web services, security? >> Get stuff done quickly with pre-integrated technology to make your job easier >> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >> _______________________________________________ >> Htmlparser-user mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/htmlparser-user >> > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > > |
From: Derrick O. <Der...@Ro...> - 2006-06-26 22:14:59
|
I think you need something like this... Parser parser = new Parser (); parser.setInputHtml (html); NodeList list = parser.parse (null); list.visitAllNodesWith (new SegmentReplacingVisitor ()); System.out.println (list.toHtml ()); ...assuming the SegmentReplacingVisitor does the right stuff to the right nodes. Mark Stark wrote: >I dont understand. I've got a html file, manipulate some tags with my >visitor, perhaps change an attribute value. and then? serialize the >toHtml() output into a file and thats it? > >Ian Macfarlane schrieb: > > >>If you do Parser.parse() you get a NodeList, and then if you call the >>toHtml() method it will return a String of the reparsed code. >> >>Ian >> >>On 6/26/06, Mark Stark <htm...@ey...> wrote: >> >> >>>hi, >>> >>>is it possible to change certain stirngs in a html file, without >>>"rebuilding" it? I would like to change some string in a html file, like >>>a dictionary lookup, but i dont want to rebuild the html file like its >>>done in URLModifyingVisitor. >>> >>>Can anybody give me a hint? I've still got >>> >>>Parser p = new Parser(); >>>p.setInputHTML(html); >>>SegmentReplacingVisitor s = new SegmentReplacingVisitor(); >>>p.visitAllNodesWith(s); >>> >>>and do some text.setText() within the SegmentReplacingVisitor each time >>>i visit a StringNode. How to save it into a translated.htm file without >>>rebuilding it? >>> >>>thanks a lot >>> >>> >>>Using Tomcat but need to do more? Need to support web services, security? >>>Get stuff done quickly with pre-integrated technology to make your job easier >>>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >>>_______________________________________________ >>>Htmlparser-user mailing list >>>Htm...@li... >>>https://lists.sourceforge.net/lists/listinfo/htmlparser-user >>> >>> >>> >>Using Tomcat but need to do more? Need to support web services, security? >>Get stuff done quickly with pre-integrated technology to make your job easier >>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >>_______________________________________________ >>Htmlparser-user mailing list >>Htm...@li... >>https://lists.sourceforge.net/lists/listinfo/htmlparser-user >> >> >> >> > > > >Using Tomcat but need to do more? Need to support web services, security? >Get stuff done quickly with pre-integrated technology to make your job easier >Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >_______________________________________________ >Htmlparser-user mailing list >Htm...@li... >https://lists.sourceforge.net/lists/listinfo/htmlparser-user > > > |
From: Mark S. <htm...@ey...> - 2006-06-27 13:45:57
|
Thanks, it works Derrick Oswald schrieb: > I think you need something like this... > > Parser parser = new Parser (); > parser.setInputHtml (html); > NodeList list = parser.parse (null); > list.visitAllNodesWith (new SegmentReplacingVisitor ()); > System.out.println (list.toHtml ()); > > ...assuming the SegmentReplacingVisitor does the right stuff to the > right nodes. > > Mark Stark wrote: > >> I dont understand. I've got a html file, manipulate some tags with my >> visitor, perhaps change an attribute value. and then? serialize the >> toHtml() output into a file and thats it? >> >> Ian Macfarlane schrieb: >> >> >>> If you do Parser.parse() you get a NodeList, and then if you call the >>> toHtml() method it will return a String of the reparsed code. >>> >>> Ian >>> >>> On 6/26/06, Mark Stark <htm...@ey...> wrote: >>> >>> >>>> hi, >>>> >>>> is it possible to change certain stirngs in a html file, without >>>> "rebuilding" it? I would like to change some string in a html file, like >>>> a dictionary lookup, but i dont want to rebuild the html file like its >>>> done in URLModifyingVisitor. >>>> >>>> Can anybody give me a hint? I've still got >>>> >>>> Parser p = new Parser(); >>>> p.setInputHTML(html); >>>> SegmentReplacingVisitor s = new SegmentReplacingVisitor(); >>>> p.visitAllNodesWith(s); >>>> >>>> and do some text.setText() within the SegmentReplacingVisitor each time >>>> i visit a StringNode. How to save it into a translated.htm file without >>>> rebuilding it? >>>> >>>> thanks a lot >>>> >>>> >>>> Using Tomcat but need to do more? Need to support web services, security? >>>> Get stuff done quickly with pre-integrated technology to make your job easier >>>> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >>>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >>>> _______________________________________________ >>>> Htmlparser-user mailing list >>>> Htm...@li... >>>> https://lists.sourceforge.net/lists/listinfo/htmlparser-user >>>> >>>> >>>> >>> Using Tomcat but need to do more? Need to support web services, security? >>> Get stuff done quickly with pre-integrated technology to make your job easier >>> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >>> _______________________________________________ >>> Htmlparser-user mailing list >>> Htm...@li... >>> https://lists.sourceforge.net/lists/listinfo/htmlparser-user >>> >>> >>> >>> >> >> >> Using Tomcat but need to do more? Need to support web services, security? >> Get stuff done quickly with pre-integrated technology to make your job easier >> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >> _______________________________________________ >> Htmlparser-user mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/htmlparser-user >> >> >> > > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > > |
From: Mark S. <htm...@ey...> - 2006-06-26 18:35:47
|
I tried to use it this way: Parser p = new Parser(); p.setInputHTML(normalHTML); System.out.println(">>>>>>> "+p.parse(null).toHtml()); TestVisitor s = new TestVisitor(); p.parse(null).visitAllNodesWith(s); System.out.println("<<<<<<<" +p.parse(null).toHtml()); In TestVisitor public void visitStringNode (Text string) { string.setText("XXX"); } The first System.out prints the original html, second System.out prints out nothing but the "<<<<". Have you any suggestions? :) Thanks a lot Ian Macfarlane schrieb: > If you do Parser.parse() you get a NodeList, and then if you call the > toHtml() method it will return a String of the reparsed code. > > Ian > > On 6/26/06, Mark Stark <htm...@ey...> wrote: >> hi, >> >> is it possible to change certain stirngs in a html file, without >> "rebuilding" it? I would like to change some string in a html file, like >> a dictionary lookup, but i dont want to rebuild the html file like its >> done in URLModifyingVisitor. >> >> Can anybody give me a hint? I've still got >> >> Parser p = new Parser(); >> p.setInputHTML(html); >> SegmentReplacingVisitor s = new SegmentReplacingVisitor(); >> p.visitAllNodesWith(s); >> >> and do some text.setText() within the SegmentReplacingVisitor each time >> i visit a StringNode. How to save it into a translated.htm file without >> rebuilding it? >> >> thanks a lot >> >> >> Using Tomcat but need to do more? Need to support web services, security? >> Get stuff done quickly with pre-integrated technology to make your job easier >> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >> _______________________________________________ >> Htmlparser-user mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/htmlparser-user >> > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > > |