Re: [Htmlparser-user] IMG tag within an A tag does not show up
Brought to you by:
derrickoswald
From: Somik R. <so...@ya...> - 2002-07-10 00:56:20
|
Hi Chris, If you want to print the html code of the link tag, just use = linkTag.toHTML(). So your code becomes : if (node instanceof HTMLLinkTag) { _pwOut.print(node.toHTML()); } Note : You dont even have to downcast bcos toHTML is in the HTMLNode = interface.=20 If you want to print all the contents yourself (for whatever reason), = then you will have to enumerate thru the data inside the link tag by = picking up an enumeration -=20 for (Enumeration e=3DlinkTag.linkData();e.hasMoreElements();) { HTMLNode node =3D (HTMLNode)e.nextElement(); // You are now enumerating thru a list of nodes inside the link tag // These could be images, strings, etc.. } Regards, Somik ----- Original Message -----=20 From: Chris=20 To: htm...@li...=20 Sent: Wednesday, July 10, 2002 3:25 AM Subject: [Htmlparser-user] IMG tag within an A tag does not show up Somik,=20 I have updated to v1.2 and it is doing well.=20 I have this problem that IMG within an A tag do not show up at all. <a href=3D"link"><img src=3D"link"></a> will come through the parser as: <a href=3D"link"></a> Code Snippet: --------------- snip --------------- if (node instanceof HTMLLinkTag) { // *********************************** // Link Tag // *********************************** HTMLLinkTag htmlTag =3D (HTMLLinkTag)node; =20 // Link Tag _pwOut.print( "<a href=3D\"" + htmlTag.getText(); + "\">" ); _pwOut.println( htmlTag.getLinkText() + "</a>" ); } --------------- snip --------------- -chris carey sublimespot.com ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Stuff, things, and much much more. http://thinkgeek.com/sf _______________________________________________ Htmlparser-user mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/htmlparser-user |