Ah. Forgive me replying to my own post -
Just read further into the DOM 2 Traversal spec,

(From section 1.2 Formal Interface Definition)
SHOW_ATTRIBUTE
Show Attr nodes. This is meaningful only when creating an iterator or
tree-walker with an attribute node as its root; in this case, it means that
the attribute node will appear in the first position of the iteration or
traversal. Since attributes are never children of other nodes, they do not
appear when traversing over the document tree.

So, it was my stupid. Looks like I'll have to rewrite the loop for the
iterator to do special things for attributes.

Thanks,
Richard.


----- Original Message -----
From: "Richard Jinks" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 09, 2002 11:28 AM
Subject: NodeIterator problems


> Hi
> Please can someone tell me whats wrong with the code sample below?
> I'm trying to use a NodeIterator to go through all nodes in my DOM tree,
but
> the code is ignoring Attribute nodes.
> I can't find anything in the API or the DOM spec to indicate that
> NodeIterators ignore attribute nodes, and I'm not using any filters, or
> limiting the whatToShow variable in any way, so as far as I'm aware, I
> should be able to see them.
>
> ...
>     DOM_Document doc;
>     DOM_NodeIterator iter;
>     DOM_Node nd;
>
>     doc=parser->getDocument();
>     nd=doc.getFirstChild();
>     iter=doc.createNodeIterator(nd,DOM_NodeFilter::SHOW_ALL,NULL, true);
>
>     while ((nd=iter.nextNode()) != 0) {
>       printf("Xerces iterator: %s\n",nd.getNodeName().transcode());
>     }
> ...
>
> As an example, this code produces the following output
>
> XML -
>
> <?xml version="1.0"?>
> <el1>
>   <el2 a="fish"></el2>
>   <el3 a="fish" b="gold"></el3>
>   <el2/>
> </el1>
>
> Output -
> Xerces iterator: "el1"
> Xerces iterator: "#text"
> Xerces iterator: "el2"
> Xerces iterator: "#text"
> Xerces iterator: "el3"
> Xerces iterator: "#text"
> Xerces iterator: "el2"
> Xerces iterator: "#text"
>
> If I change the whatToShow to DOM_NodeFilter::SHOW_ATTRIBUTE then nothing
is
> output.
>
> Thanks for any help,
> Richard
>
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to