Hi John,
Why not have a class that responsible for maintaining the DOM list and
have everything else make calls into it. That way you also hide all of
the xerces specific code in case you later need to swap out with another
parser. Also, if you want to thread your code, you'll need to protect
the DOM structure and the class you build would be able to handle that.
We use something similar to this in our main app. I'd be happy to give
you more details if you wish.
Scott
[EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
>
> Hi,
>
> I'm not sure what the best way to accomplish this task is. I would like to
> create my own node list by collecting nodes from various DOM API's. Then
> I'd like to use those nodes by passing the list around to different
> functions in my code.
>
> I know the following will not work:
>
> DOM_NodeList domNodeList = getAllChildNodes();
> DOMString dsTemp,dsName;
> dsName = transcode("someNameImLookingFor);
> int listLength = domNodeList.getLength();
>
> for(int i= 0; i<listLength ;i++){
> if(dsName.equals(domNodeList.item(i).getNodeName())) {
> // myNodeList is a linked list of DOM_Node *
> myNodeList->append(&(domNodeList.item(i)) );
> }
> }
>
> Here I'm keeping a list of DOM_Node pointers which from what I've read on
> this list archive as well as the doc's is a very bad thing to do.
>
> I came across a post from [EMAIL PROTECTED] that contained this
> snippet:
>
> for (Node n=myparentelement.getFirstChild();
> n!=null;
> n=n.getNextSibling() )
> {
> if(givenTagname.equals(n.getNodeName()))
> {
> ...process it, or add to a list for later processing...
> }
> }
>
> Note that he says "...process it, or add to a list for later processing...
> This is what I want to do, but how do I construct and use the list he is
> talking about.
>
> I'm getting the feeling that I should probably avoid all this by using a
> treewalker or nodeiterator, but I would still like to know how to keep my
> own list.
>
> Thanks,
>
> John
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]