RE: [Htmlparser-developer] Label Tag
Brought to you by:
derrickoswald
From: <dha...@or...> - 2003-05-01 10:27:44
|
Hi, >> I was thinking of a setLabel wherein the user would >> give a single string >> (it might have many tags). Internally, setLabel() >> would parse it into >> its corresponding tags and assign it as the children >> of the Label tag. >> What do you guys think? Lemme know. > That would work - but would be costly (in > performance). You really dont want to rig up an > internal parser just to change the label tag data. > A simpler way is to find out which string node you > wish to change (digupStringNode(), searchFor(), or > quite simply, the exact index which you might happen > to know). > Then, > StringNode newNode = new StringNode( > newDataBuffer, 0, 0 > ); > To replace the child, you can either do something as > simple as, > getChildrenAsNodeArray()[posOfOldNode] = newNode; > > or > NodeList nodeList = getChildren(); > and make a similar modification in the nodelist. Understood. However in this mechanism the number of new nodes that I might want to replace will be limited by the number of nodes already present. Furthermore, I can't even reduce the number of nodes. For example there may have been 5 child nodes earlier but now there are only 2. I believe by explicitly setting each array element to null may be the only option. Another aspect is that the API user needs to be aware of all these other classes(StringNode, NodeList, Node etc..). can we have some mechanism by which an API user is isolated from all this and gets functionality as I xplained above. Dhaval |