Re: [Htmlparser-user] Bug in HTMLFrameTag ?
Brought to you by:
derrickoswald
From: Somik R. <so...@ya...> - 2003-02-05 18:37:07
|
--- Elodie Tasia <et...@in...> wrote: > I answer to myself ;o) I think I've found the source > of my problem. > I've added : > > parser.addScanner( new HTMLFrameSetScanner() ); > parser.addScanner( new HTMLFrameScanner() ); > > to my code, and it seems to work now. > But I've discored another problem : if there is one > or many <frameset> tags included in a <frameset>, > they are not detected (only the <frame> tags). > > Could someone confirm me that, or I'm totally wrong > ? There are many ways to get to the child tags. Here are some : Assuming you have got the first frameset tag for (SimpleEnumeration e = firstFrameSetTag.children(); e.hasMoreNodes(); ) { HTMLNode node = e.nextNode(); if (node instanceof HTMLFrameSetTag) { HTMLFrameSetTag frameSetTag = (HTMLFrameSetTag)node; } if (node instanceof HTMLFrameTag) { HTMLFrameTag frameTag = (HTMLFrameTag)node; } } ALTERNATIVELY: If you are only interested in frameset tags, parser = new HTMLParser(..); parser.registerScanners(); HTMLNode [] frameSetTags = parser.extractAllNodesThatAre(HTMLFrameSetTag.class); If you are interested in both frameset and frame, a cleaner approach is : public class MyParserVisitor extends HTMLVisitor { public void visitTag(HTMLTag tag) { if (tag.getTagName().equals("FRAMESET") || tag.getTagName().equals("FRAME") { // Do what you want to do. } } public void get..() { } } parser = new HTMLParser(..); MyParserVisitor myParserVisitor = new MyParserVisitor(); parser.visitAllNodesWith(myParserVisitor); myParserVisitor.get..(); Regards, Somik __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com |