Re: [Htmlparser-user] Replace LinkTag nodes with a Text node containing ~node.toString()
Brought to you by:
derrickoswald
From: Derrick O. <Der...@Ro...> - 2006-05-19 12:01:13
|
If you want to replace all tags with plain text use the StringBean class to return the text contents of a page. If it's just the LinkTag nodes you want to replace, its a bit more complicated. Perhaps the easiest way would be to create your own derived LinkTag class and override it's toHtml() method to just return the toHtml() or toPlainTextString() of all it's children, without the enclosing <A> and </A>. You would then register an instance of this custom tag with a PrototypicalNodeFactory and pass the factory to the parser via setNodeFacory(). Then when you print the toHtml() of the NodeList returned from the parser, the overridden method is called and your tag get's to do it's thing in the midst of the page. Smarty wrote: > > Hi everyone. > > Could you please tell me the easiest way to transform all LinkTag > nodes from a NodeList to Text nodes that contain the text of the > link's children? > > From an html standpoint this should convert > > This is a <a href=''><b>link</b></a>... > > to > > This is a link... > > or > > This is a <a href=''><b>link</b></a>... > > to > > This is a <b>link</b>... > > (both ways are ok for me) > > > Thanks for your time, > Ovidiu Dan |