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]

Reply via email to