void XmlParse::InitXml(rapidxml::xml_document<> &doc) { xml_node<> *node = doc.allocate_node(node_declaration, "", ""); doc.append_node(node); xml_attribute<> *attr1 = doc.allocate_attribute("version", "1.0"); xml_attribute<> *attr2 = doc.allocate_attribute("encoding", "UTF-8"); node->append_attribute(attr1); node->append_attribute(attr2); }
void TacheUnitaire::xml_ajouterAttributs(rapidxml::xml_document<> & doc, rapidxml::xml_node<> & node_tache) { using namespace rapidxml; xml_attribute<> * attribute = doc.allocate_attribute("type", "u"); node_tache.append_attribute(attribute); if(getPreempte() == true) { attribute = doc.allocate_attribute("pre", "true"); node_tache.append_attribute(attribute); } char * node_name = doc.allocate_string( duree.toChar() ); attribute = doc.allocate_attribute( "duree", node_name ); node_tache.append_attribute(attribute); }
void XmlTree::appendRapidXmlNode( rapidxml::xml_document<char> &doc, rapidxml::xml_node<char> *parent ) const { rapidxml::node_type type; switch( getNodeType() ) { case XmlTree::NODE_ELEMENT: type = rapidxml::node_element; break; case XmlTree::NODE_COMMENT: type = rapidxml::node_comment; break; case XmlTree::NODE_CDATA: type = rapidxml::node_cdata; break; case XmlTree::NODE_DATA: type = rapidxml::node_data; break; default: throw ExcUnknownNodeType(); } rapidxml::xml_node<char> *node = 0; if( type == rapidxml::node_data ) { node = doc.allocate_node( type, NULL, doc.allocate_string( getValue().c_str() ) ); } else if( type == rapidxml::node_comment ) { node = doc.allocate_node( type, doc.allocate_string( getTag().c_str() ), doc.allocate_string( getValue().c_str() ) ); } else { node = doc.allocate_node( type, doc.allocate_string( getTag().c_str() ), NULL ); if( ! getValue().empty() ) node->append_node( doc.allocate_node( rapidxml::node_data, NULL, doc.allocate_string( getValue().c_str() ) ) ); } parent->append_node( node ); for( list<Attr>::const_iterator attrIt = mAttributes.begin(); attrIt != mAttributes.end(); ++attrIt ) node->append_attribute( doc.allocate_attribute( doc.allocate_string( attrIt->getName().c_str() ), doc.allocate_string( attrIt->getValue().c_str() ) ) ); for( Container::const_iterator childIt = mChildren.begin(); childIt != mChildren.end(); ++childIt ) (*childIt)->appendRapidXmlNode( doc, node ); }
void CTest::AddXMLAttributeValue( rapidxml::xml_document<>& pDoc, rapidxml::xml_node<>* pNode, const std::wstring& strwKey, const std::wstring& strwValue ) { std::string straValue = wstr2str(strwValue, CP_UTF8); std::string strakey = wstr2str(strwKey, CP_UTF8); pNode->append_attribute(pDoc.allocate_attribute(pDoc.allocate_string(strakey.c_str()), pDoc.allocate_string(straValue.c_str()) ) ); }