Пример #1
0
void experiment_datasets::decode_xml_node(rapidxml::xml_node<> & node)
{
	using namespace rapidxml;


	assert (string("experiment_datasets") == node.name());

	train_test_pairs.resize(0);
	xml_node<> * train_test_pairs_node = node.first_node("train_test_pairs");
	for (xml_node<> * train_test_pair_node = train_test_pairs_node->first_node("train_test_pair");
		train_test_pair_node != 0 ; train_test_pair_node = train_test_pair_node->next_sibling("train_test_pair"))
	{
		shared_ptr<train_test_pair> p_train_test_pair = deserialize<train_test_pair>(train_test_pair_node);
		train_test_pairs.push_back(*p_train_test_pair);
	}

}
Пример #2
0
void parseItem( const rapidxml::xml_node<> &node, XmlTree *parent, XmlTree *result, const XmlTree::ParseOptions &options )
{
	*result = XmlTree( node.name(), node.value(), parent );
	for( const rapidxml::xml_node<> *item = node.first_node(); item; item = item->next_sibling() ) {
		XmlTree::NodeType type;
		switch( item->type() ) {
			case rapidxml::node_element:
				type = XmlTree::NODE_ELEMENT;
			break;
			case rapidxml::node_cdata: {
				if( options.getCollapseCData() ) {
					result->setValue( result->getValue() + item->value() );
					continue;
				}
				else {
					type = XmlTree::NODE_CDATA;
				}
			}
			break;						
			case rapidxml::node_comment:
				type = XmlTree::NODE_COMMENT;
			break;
			case rapidxml::node_doctype: {
				result->setDocType( item->value() );
				continue;
			}
			case rapidxml::node_data: {
				if( ! options.getIgnoreDataChildren() )
					type = XmlTree::NODE_DATA;
				else
					continue;
			}
			break;
			default:
				continue;
		}
		
		result->getChildren().push_back( unique_ptr<XmlTree>( new XmlTree ) );
		parseItem( *item, result, result->getChildren().back().get(), options );
		result->getChildren().back()->setNodeType( type );
	}

	for( rapidxml::xml_attribute<> *attr = node.first_attribute(); attr; attr = attr->next_attribute() )
		result->getAttributes().push_back( XmlTree::Attr( result, attr->name(), attr->value() ) );
}
Пример #3
0
//===========================================
// XmlNode::name
//===========================================
inline std::string XmlNode::name() const {
   if (isNull()) throw XmlException("Node is NULL", __FILE__, __LINE__);
   return std::string(m_node->name(), m_node->name_size());
}