Re: [Htmlparser-developer] Label Tag
Brought to you by:
derrickoswald
From: Somik R. <so...@ya...> - 2003-04-27 22:54:13
|
Hi Dhaval, > I want to parse a LABEL tag and replace the data between the start and end > tags. I am able to obtain the data using the getLabel method. However to > replace, firstly there is no synonymous setLabel() method. Hence I used the > setText() method of Tag class. After that I printed my tag using the toHtml() > method. However I received the previous text itself, not the one I replaced. You cannot and should not rely on setText() to change tag contents. setText() is used by certain automata during the process of parsing itself, for special reasons ( link tag modifying the url, image tag doing the same..) In order to change contents within the tag, use setAttribute(). But.. that doesent help u, does it ? :) You need to evolve the LabelTag interface, to have setLabel - which maps on to the children of the label tag. Setting the text involves creation of string nodes and adding them as children to the label (don't forget to delete the previous children). I've added getChildren() to CompositeTag to help you out. > Also the following is required: > 1. Obviously toHtml() must consider the changed text. Nope. toHtml() considers the internal tag representation alone. You should map to that in the specific tag code. > 2. LabelTag should have setLabel() method synoymous to getLabel() which > internally calls setText() of Tag class. Yes- it will be great if you can write setLabel() - and no, it should not call setText(). Regards, Somik |