Re: [Htmlparser-user] Getting all tags??
Brought to you by:
derrickoswald
|
From: Derrick O. <Der...@Ro...> - 2006-04-26 01:07:23
|
You will need to cast it to a tag if possible and use getTagName ():
if (node instanceof Tag)
System.out.println (((Tag)node).getTagName ());
Thomas Zastrow wrote:
> Derrick Oswald schrieb:
>
>> Sorry about that. I fixed the ocumentation. Just supply a null...
>> NodeList list = parser.parse (null);
>> Note that the tags will be nested so the list is only as long as the
>> count of enclosing tags, usually just one, i.e. <HTML>.
>>
>> If you want nodes in a simple sequential order without nesting, use
>> the lexer...
>> Parser parser = new Parser ("http://whatever");
>> Lexer lexer = parser.getLexer ();
>> Node node;
>> while (null != (node = lexer.nextNode ())
>> ... do something with the node
>>
> Dear Derrick,
>
> thank you for your help ;-)
>
> So, maybe I can ask another question ... I got this code:
>
> Parser parser = new
> Parser("/gb/testfiles/abraham/fabeln/antwort.htm");
> Lexer lexer = parser.getLexer();
> Node node;
> String s;
> while(null != lexer.nextNode()){
> node = lexer.nextNode();
> s = node.toPlainTextString();
> System.out.println(s);
> }
>
> Works fine, but it prints me the content of the tags, not the names of
> the tags? But I just need to know which tags are used in the document...
>
> Thank you very much!
>
> Greetings,
>
> Tom
>
>
>
> -------------------------------------------------------
> 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
>
|