I'm a novice to both XML authoring and Xerces so I'm working from samples to get everything set up. I've started a simple program to parse my sample .xml and output it's contents. I was expecting several ELEMENT_NODEs and a few TEXT_NODEs, however my output indicates that everything in my .xml is a TEXT_NODE. This is preventing me from being able to access the actual element name, and is returning #text as the node name for every node in the DOM tree. Any suggestions on why this is occurring and how to correctly identify the elements as ELEMENT_NODEs? Thanks! Here's the pertinent code: // create tree walker to traverse all elements in the DOMDocument Tree DOMElement *docRoot = document->getDocumentElement(); // get root to give walker DOMTreeWalker* walker = document->createTreeWalker(docRoot, DOMNodeFilter::SHOW_TEXT, NULL, true); DOMNode* curNode; // traverse the DOMDocument while ((curNode = walker->nextNode()) != NULL) { // print out information on the nodes char* strValue = XMLString::transcode(curNode->getNodeValue()); printf("Nodes Value is: %s \n ", strValue); XMLString::release(&strValue);
DOMNode::NodeType type = curNode->getNodeType(); printf("Node Type: %d \n", type); char* strName = XMLString::transcode(curNode->getNodeName()); printf("Node Name: %s \n", strName); XMLString::release(&strName); char* strContent = XMLString::transcode(curNode->getTextContent()); printf("Node Content: %s \n", strContent); XMLString::release(&strContent); } And here's the output Nodes Value is: Node Type: 3 Node Name: #text Node Content: Nodes Value is: Node Type: 3 Node Name: #text Node Content: Nodes Value is: 1001 Node Type: 3 Node Name: #text Node Content: 1001 Nodes Value is: Node Type: 3 Node Name: #text Node Content: Nodes Value is: Jag Node Type: 3 Node Name: #text Node Content: Jag Nodes Value is: Node Type: 3 Node Name: #text Node Content: Nodes Value is: 27 Node Type: 3 Node Name: #text Node Content: 27 Nodes Value is: Node Type: 3 Node Name: #text Node Content: Nodes Value is: Node Type: 3 Node Name: #text Node Content: And here's the .xml <?xml version="1.0" encoding="UTF-8"?> <Employees xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance <http://www.w3.org/2001/XMLSchema-instance> " xsi:noNamespaceSchemaLocation="C:\. . .\Employees.xsd"> <Employee> <ID>1001</ID> <Name>Jag</Name> <Age>27</Age> </Employee> </Employees> And the schema (for good measure) <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Employees"> <xs:annotation> <xs:documentation>Contains All Employee information</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element name="Employee" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="ID" type="xs:string"/> <xs:element name="Name" type="xs:string"/> <xs:element name="Age" type="xs:int"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> <mailto:kimberly.stew...@bsci.com>