Xerces, by default, and I know of no way to turn this off if you don't have a dtd, inserts whitespace into the DOM tree as text nodes. So it looks to me that you have a file with the contents: <model> <scale>0.025</scale> </model>
I would recommend adjusting the contents to not have any whitespace. e.g.: <model><scale>0.025</scale></model> Or the other alternative is to implement a cleanup function that walks the entire tree and removes nodes that are nothing but whitespace. I have a bunch of experimental code that happens to do this: http://www.openaether.org/src/source/framework/xmlutil.cpp#L135 Feel free to steal it, or improve it... if you do let me know ;) On Tue, 2002-10-01 at 00:16, Ken Miller wrote: > I am creating a linked list when parsing through a DOM document and > having a small problem. When the node is an element node, I check to > see if there are more children or siblings and then handle the linked > list accordingly. The problem is that it seems that every node is > treated as a sibling, so a dummy sibling node is created after each > node. When an actual child is found, it is placed under the dummy > sibling node instead of the actual node. For example, I get the > following when reading an XML file that has a node called 'model' and a > child called 'scale': > > Name: model > Value: > Name: * > Value: * > Name: scale > Value: 0.025 > > This shows the dummy sibling (marked with the *) and the scale child > node added under the dummy node vice the 'model' node. The * in the > name and value is just what is put into those fields when the new linked > list node is created and is not added from the XML file. > > Any ideas on what I am doing wrong? I have included the code snippet > below. > > Thanks. > > Ken > > part of a buildList function: > > case DOM_Node::ELEMENT_NODE : > { > strcpy(currentPtr->elementName, nodeName.transcode()); > > // Output any attributes on this element > DOM_NamedNodeMap attributes = toWrite.getAttributes(); > int attrCount = attributes.getLength(); > for (int i = 0; i < attrCount; i++) > { > DOM_Node attribute = attributes.item(i); > } > > DOM_Node child = toWrite.getFirstChild(); > if (child != 0) > { > while( child != 0) > { > DOMString tmpName = child.getNodeName(); > if(child.getNodeType() != DOM_Node::TEXT_NODE) { > addChildToNode(currentPtr); > buildList(child, currentPtr->child); > } > else { > buildList(child, currentPtr); > } > > child = child.getNextSibling(); > if(child != 0) { > DOMString tmpName = child.getNodeName(); > if(strcmp(tmpName.transcode(), "#text") != 0) { > addSiblingToNode(currentPtr); > currentPtr = currentPtr->rSibling; > } > > } > } > > } > break; > } > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
