// internal helper function to process elements void processXMLElement(XMLHandler& handler, xmlNode* node) { // build attributes block for the element XMLAttributes attrs; xmlAttrPtr currAttr = node->properties; while (currAttr) { xmlChar* val = xmlGetProp(node, currAttr->name); attrs.add((utf8*)currAttr->name, (utf8*)val); xmlFree(val); currAttr = currAttr->next; } // element start processing handler.elementStart((utf8*)node->name, attrs); for (xmlNode* cur_node = node->children; cur_node; cur_node = cur_node->next) { switch(cur_node->type) { case XML_ELEMENT_NODE: processXMLElement(handler, cur_node); break; case XML_TEXT_NODE: if (cur_node->content != 0 && *cur_node->content!= '\0') handler.text((utf8*)cur_node->content); break; } } // element end processing handler.elementEnd((utf8*)node->name); }
void ExpatParser::startElement(void* data, const char* element, const char** attr) { XMLHandler* handler = static_cast<XMLHandler*>(data); XMLAttributes attrs; for(size_t i = 0 ; attr[i] ; i += 2) attrs.add((const encoded_char*)attr[i], (const encoded_char*)attr[i+1]); handler->elementStart((const encoded_char*)element, attrs); }
//----------------------------------------------------------------------------// void RapidXMLDocument::processElement(const rapidxml::xml_node<>* element) { // build attributes block for the element XMLAttributes attrs; rapidxml::xml_attribute<>* currAttr = element->first_attribute(0); while (currAttr) { attrs.add((utf8*)currAttr->name(), (utf8*)currAttr->value()); currAttr = currAttr->next_attribute(); } // start element d_handler->elementStart((utf8*)element->name(), attrs); // do children rapidxml::xml_node<>* childNode = element->first_node(); while (childNode) { switch (childNode->type()) { case rapidxml::node_element: processElement(childNode); break; case rapidxml::node_data: if (childNode->value() != '\0') d_handler->text((utf8*)childNode->value()); break; // Silently ignore unhandled node type }; childNode = childNode->next_sibling(); } // end element d_handler->elementEnd((utf8*)element->name()); }
void TinyXMLDocument::processElement(const TiXmlElement* element) { // build attributes block for the element XMLAttributes attrs; const TiXmlAttribute *currAttr = element->FirstAttribute(); while (currAttr) { attrs.add((encoded_char*)currAttr->Name(), (encoded_char*)currAttr->Value()); currAttr = currAttr->Next(); } // start element d_handler->elementStart((encoded_char*)element->Value(), attrs); // do children const TiXmlNode* childNode = element->FirstChild(); while (childNode) { switch(childNode->Type()) { case TiXmlNode::CEGUI_TINYXML_ELEMENT: processElement(childNode->ToElement()); break; case TiXmlNode::CEGUI_TINYXML_TEXT: if (childNode->ToText()->Value() != '\0') d_handler->text((encoded_char*)childNode->ToText()->Value()); break; // Silently ignore unhandled node type }; childNode = childNode->NextSibling(); } // end element d_handler->elementEnd((encoded_char*)element->Value()); }