当前位置: 首页>>代码示例>>C++>>正文


C++ xml_document类代码示例

本文整理汇总了C++中xml_document的典型用法代码示例。如果您正苦于以下问题:C++ xml_document类的具体用法?C++ xml_document怎么用?C++ xml_document使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了xml_document类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ftof_volumes_xml

void ftof_volumes_xml(xml_document& doc, const ForwardTOF& ftof)
{
    // start building up the XML document
    xml_node geom_node = doc.child("geometry");
    if (!geom_node)
    {
        geom_node = doc.append_child("geometry");
    }
    xml_node dc_node = geom_node.child("forward_tof");
    if (!dc_node)
    {
        dc_node = geom_node.append_child("forward_tof");
    }
    xml_node vol_node = dc_node.child("volumes");
    if (!vol_node)
    {
        vol_node = dc_node.append_child("volumes");
    }

    for (auto k1 : ftof_volumes_map(ftof))
    {
        xml_node n1 = vol_node.append_child(k1.first.c_str());

        for (auto k2 : k1.second)
        {
            xml_node n2 = n1.append_child(k2.first.c_str());
            n2.append_child(node_pcdata).set_value(k2.second.c_str());
        }
    }
}
开发者ID:theodoregoetz,项目名称:clas12_geometry,代码行数:30,代码来源:ftof_volumes.hpp

示例2: dc_core_params_xml

void dc_core_params_xml(xml_document& doc, const DriftChamber& dc, const string& units="cm")
{
    double lconv = length_conversion(units);

    // start building up the XML document
    xml_node geom_node = doc.child("geometry");
    if (!geom_node)
    {
        geom_node = doc.append_child("geometry");
    }

    xml_node dc_node = geom_node.child("drift_chamber");
    if (!dc_node)
    {
        dc_node = geom_node.append_child("drift_chamber");
    }

    xml_node params_node = dc_node.append_child("core_params");

    for (int nreg : vector<int>{0, 1, 2})
    {
        xml_node reg_node = params_node.append_child("region");
        reg_node.append_attribute("index") = nreg;

        for (int nslyr : vector<int>{0, 1})
        {
            xml_node slyr_node = reg_node.append_child("superlayer");
            slyr_node.append_attribute("index") = nslyr;

            slyr_node.append_attribute("wpdist") = dc.sector(0).region(nreg).superlayer(nslyr).wpdist() * lconv;
        }
    }
}
开发者ID:JeffersonLab,项目名称:clas12_geometry,代码行数:33,代码来源:dc_core_params.hpp

示例3: AppendAttribute

void XmlParse::AppendAttribute(const std::string &NewAttributeName, const std::string &NewAttributeValue,
                               xml_document<> &doc, xml_node<> *ParentNode)
{
    xml_attribute<> *attr = doc.allocate_attribute(doc.allocate_string(NewAttributeName.c_str()),
                            doc.allocate_string(NewAttributeValue.c_str()));
    if (ParentNode)
    {
        ParentNode->append_attribute(attr);
    }
}
开发者ID:ponlee,项目名称:test,代码行数:10,代码来源:XmlParse.cpp

示例4: read_properties_core

void workbook_serializer::read_properties_core(const xml_document &xml)
{
    auto &props = workbook_.get_properties();
    auto root_node = xml.get_child("cp:coreProperties");

    props.excel_base_date = calendar::windows_1900;

    if (root_node.has_child("dc:creator"))
    {
        props.creator = root_node.get_child("dc:creator").get_text();
    }
    if (root_node.has_child("cp:lastModifiedBy"))
    {
        props.last_modified_by = root_node.get_child("cp:lastModifiedBy").get_text();
    }
    if (root_node.has_child("dcterms:created"))
    {
        std::string created_string = root_node.get_child("dcterms:created").get_text();
        props.created = w3cdtf_to_datetime(created_string);
    }
    if (root_node.has_child("dcterms:modified"))
    {
        std::string modified_string = root_node.get_child("dcterms:modified").get_text();
        props.modified = w3cdtf_to_datetime(modified_string);
    }
}
开发者ID:lyntel,项目名称:xlnt,代码行数:26,代码来源:workbook_serializer.cpp

示例5: load_document_copy

static void load_document_copy(xml_document& doc, const char_t* text)
{
	xml_document source;
	CHECK(source.load(text));

	doc.append_copy(source.first_child());
}
开发者ID:antialize,项目名称:pugixml,代码行数:7,代码来源:test_xpath.cpp

示例6: load_concat

static xml_parse_result load_concat(xml_document& doc, const char_t* a, const char_t* b = STR(""), const char_t* c = STR(""))
{
	char_t buffer[768];

#ifdef PUGIXML_WCHAR_MODE
	wcscpy(buffer, a);
	wcscat(buffer, b);
	wcscat(buffer, c);
#else
	strcpy(buffer, a);
	strcat(buffer, b);
	strcat(buffer, c);
#endif

	return doc.load(buffer, parse_fragment);
}
开发者ID:DamianPrg,项目名称:pugixml,代码行数:16,代码来源:test_parse_doctype.cpp

示例7: LoadXMLFile

bool RawInputParser::LoadXMLFile(xml_document& doc,const string& filePath) const
{
	xml_parse_result result = doc.load_file(filePath.c_str());

	bool returnResult = false;

	if (result)
	{
		LOG("XML [" << filePath << "] parsed without errors\n");
		returnResult = true;
	}
	else
	{
		LOG("XML [" << filePath << "] parsed with errors\n");
		LOG("Error description: " << result.description() << "\n");
		LOG("Error offset: " << result.offset << "\n");
		returnResult = false;
	}

	return returnResult;
}
开发者ID:CSPshala,项目名称:dangerzone,代码行数:21,代码来源:RawInputParser.cpp

示例8: write_xml

/// Initialize the XML DOM structure (leaving .desc unchanged) from the data.
void stream_info_impl::write_xml(xml_document &doc) {
	const char *channel_format_strings[] = {"undefined","float32","double64","string","int32","int16","int8","int64"};
	xml_node info = doc.append_child("info");
	info.append_child("name").append_child(node_pcdata).set_value(name_.c_str());
	info.append_child("type").append_child(node_pcdata).set_value(type_.c_str());
	info.append_child("channel_count").append_child(node_pcdata).set_value(lexical_cast<string>(channel_count_).c_str());
	info.append_child("nominal_srate").append_child(node_pcdata).set_value(lexical_cast<string>(nominal_srate_).c_str());
	info.append_child("channel_format").append_child(node_pcdata).set_value(channel_format_strings[channel_format_]);
	info.append_child("source_id").append_child(node_pcdata).set_value(source_id_.c_str());
	info.append_child("version").append_child(node_pcdata).set_value(lexical_cast<string>(version_/100.0).c_str());
	info.append_child("created_at").append_child(node_pcdata).set_value(lexical_cast<string>(created_at_).c_str());
	info.append_child("uid").append_child(node_pcdata).set_value(uid_.c_str());
	info.append_child("session_id").append_child(node_pcdata).set_value(session_id_.c_str());
	info.append_child("hostname").append_child(node_pcdata).set_value(hostname_.c_str());
	info.append_child("v4address").append_child(node_pcdata).set_value(v4address_.c_str());
	info.append_child("v4data_port").append_child(node_pcdata).set_value(lexical_cast<string>(v4data_port_).c_str());
	info.append_child("v4service_port").append_child(node_pcdata).set_value(lexical_cast<string>(v4service_port_).c_str());
	info.append_child("v6address").append_child(node_pcdata).set_value(v6address_.c_str());
	info.append_child("v6data_port").append_child(node_pcdata).set_value(lexical_cast<string>(v6data_port_).c_str());
	info.append_child("v6service_port").append_child(node_pcdata).set_value(lexical_cast<string>(v6service_port_).c_str());
	info.append_child("desc");
}
开发者ID:MindContact,项目名称:labstreaminglayer,代码行数:23,代码来源:stream_info_impl.cpp

示例9: toElementText

   std::string path::toElementText( xml_document const& _doc )const {

      path key_no_attr = *this;

      if( key_no_attr.points_to_attr() ) {
         path_element& pel = key_no_attr.last();
         pel.attr( path_attr() );
      }// debug

      string pathadd = key_no_attr;

      if( pathadd == "domain.features.apic" ) {
         pathadd = key_no_attr;
      }

      element_locator locator( key_no_attr );

      _doc.accept( &locator );

      xml_element* elem = locator.elementfound();

      if( elem != nullptr ) {
         xml_node const* ch = elem->first_child();

         if( ch == nullptr ) {
            return "nullptr";
         }

         xml_text const* p1 = dynamic_cast<xml_text const*>( ch );
         string txt = p1->value();
         return txt;

      }


      return "";

   }
开发者ID:rleofield,项目名称:xmlparser,代码行数:38,代码来源:key_path.cpp

示例10: read_shared_strings

bool shared_strings_serializer::read_shared_strings(const xml_document &xml, std::vector<std::string> &strings)
{
    strings.clear();

    auto root_node = xml.get_child("sst");
    auto unique_count = 0;

    if (root_node.has_attribute("uniqueCount"))
    {
        unique_count = std::stoull(root_node.get_attribute("uniqueCount"));
    }

    for (const auto &si_node : root_node.get_children())
    {
        if (si_node.get_name() != "si")
        {
            continue;
        }

        if (si_node.has_child("t"))
        {
            strings.push_back(si_node.get_child("t").get_text());
        }
        else if (si_node.has_child("r"))
        {
            strings.push_back(si_node.get_child("r").get_child("t").get_text());
        }
    }

    if (unique_count != strings.size())
    {
        throw std::runtime_error("counts don't match");
    }

    return true;
}
开发者ID:lyntel,项目名称:xlnt,代码行数:36,代码来源:shared_strings_serializer.cpp

示例11: writeCreateSchemeXml

/**
 * @brief WrapperXml::writeXml, metodo para escribir un xml
 * @param pRuta, directorio en el que se guardara el documento
 * @param pRoot, raiz del documento
 * @param pSon, hijo del documento
 */
void WrapperXml::writeCreateSchemeXml(std::string pMsg, xml_document<> &pDocument){
    xml_node<>* decl = pDocument.allocate_node(node_declaration);
    decl->append_attribute(pDocument.allocate_attribute(VERSION, NUMVERSION));
    decl->append_attribute(pDocument.allocate_attribute(ENCODE, TYPEENCODE));
    pDocument.append_node(decl);

    xml_node<>* root = pDocument.allocate_node(node_element, SCHEME);
    pDocument.append_node(root);

    std::istringstream pBuffer(pMsg);
    std::string subString;
    pBuffer >> subString;
    xml_node<>* childSN = pDocument.allocate_node(node_element, SCHEMENAME);
    childSN->value(strdup(subString.c_str()));
    root->append_node(childSN);
    pBuffer >> subString;
    xml_node<>* childR = pDocument.allocate_node(node_element, RAID);
    childR->value(strdup(subString.c_str()));
    root->append_node(childR);

    while(pBuffer){
        pBuffer >> subString;
        if(subString==HASH)
            break;
        else{
            xml_node<>* childD = pDocument.allocate_node(node_element, DATA);
            xml_node<>* childDT = pDocument.allocate_node(node_element, DATATYPE);
            childDT->value(strdup(subString.c_str()));
            childD->append_node(childDT);
            pBuffer >> subString;
            xml_node<>* childDL = pDocument.allocate_node(node_element, DATANAME );
            childDL->value(strdup(subString.c_str()));
            childD->append_node(childDL);
            pBuffer >> subString;
            xml_node<>* childDN= pDocument.allocate_node(node_element, DATANAME);
            childDN->value(strdup(subString.c_str()));
            childD->append_node(childDN);
            root->append_node(childD);
        }
    }

}
开发者ID:DatosII,项目名称:ClienteInmemdb,代码行数:48,代码来源:wrapperxml.cpp

示例12: ftof_panels_parms_xml

void ftof_panels_parms_xml(xml_document& doc, const ForwardTOF& ftof, const string& coordsys="clas", const string& units="cm")
{
    double lconv = length_conversion(units);

    if (coordsys != "sector" && coordsys != "clas")
    {
        throw runtime_error(string("can not generate data in ") + coordsys + " coordinates");
    }
    coordsys_t coord = str2coord(coordsys);

    // start building up the XML document
    xml_node geom_node = doc.child("geometry");
    if (!geom_node)
    {
        geom_node = doc.append_child("geometry");
    }

    xml_node ftof_node = geom_node.child("forward_tof");
    if (!ftof_node)
    {
        ftof_node = geom_node.append_child("forward_tof");
    }

    xml_node panels_node = ftof_node.child("panels_parms");
    if (!panels_node)
    {
        panels_node = ftof_node.append_child("panels_parms");
        panels_node.append_attribute("length_units");
        panels_node.append_attribute("coordinate_system");
    }

    panels_node.attribute("length_units") = units.c_str();
    panels_node.attribute("coordinate_system") = coordsys.c_str();

    for (int sec=0; sec<ftof.sectors().size(); sec++)
    {
        const forward_tof::Sector& ftof_sector = ftof.sector(sec);

        for (int pan=0; pan<ftof_sector.panels().size(); pan++)
        {
            const forward_tof::Panel& panel = ftof_sector.panel(pan);

            xml_node panel_node = panels_node.append_child("panel");
            panel_node.append_attribute("sector") = sec;
            panel_node.append_attribute("panel") = ftof_sector.panel_name(pan).c_str();
            panel_node.append_attribute("npaddles") = int(panel.npaddles());
            panel_node.append_attribute("dist2tgt") = panel.dist2tgt() * lconv;

            direction_vector<double,3> panel_norm = panel.panel_normal(coord);
            panel_node.append_attribute("norm_phi") = panel_norm.phi();
            panel_node.append_attribute("norm_theta") = panel_norm.theta();

            direction_vector<double,3> paddle_dir = panel.paddle_direction(coord);
            panel_node.append_attribute("paddle_phi") = paddle_dir.phi();
            panel_node.append_attribute("paddle_theta") = paddle_dir.theta();

            panel_node.append_attribute("paddle_width") = panel.paddle_width() * lconv;
            panel_node.append_attribute("paddle_thickness") = panel.paddle_thickness() * lconv;

            euclid_vector<double,3> paddle_extent = panel.paddle_extent(COORDSYS::SECTOR);
            panel_node.append_attribute("paddle_extent_x") = paddle_extent.x() * lconv;
            panel_node.append_attribute("paddle_extent_z") = paddle_extent.z() * lconv;

            xml_node center_node = panel_node.append_child("paddle_centers");
            vector<xml_node> paddle_centers_node;
            paddle_centers_node.push_back(center_node.append_child("x"));
            paddle_centers_node.push_back(center_node.append_child("y"));
            paddle_centers_node.push_back(center_node.append_child("z"));

            vector<stringstream> centers(3);
            for (auto cntr : panel.paddle_centers(coord))
            {
                centers[0] << " " << cntr.x() * lconv;
                centers[1] << " " << cntr.y() * lconv;
                centers[2] << " " << cntr.z() * lconv;
            }
            for (int i=0; i<paddle_centers_node.size(); i++)
            {
                paddle_centers_node[i].append_child(pugi::node_pcdata).set_value(
                    centers[i].str().erase(0,1).c_str());
            }

            xml_node length_node = panel_node.append_child("paddle_lengths");
            stringstream lengths;
            for (auto lngth : panel.paddle_lengths())
            {
                lengths << " " << lngth;
            }
            length_node.append_child(pugi::node_pcdata).set_value(
                lengths.str().erase(0,1).c_str());
        }
    }
}
开发者ID:JeffersonLab,项目名称:clas12_geometry,代码行数:93,代码来源:ftof_panels_parms.hpp

示例13: loadSRSML

void loadSRSML()
{

	cout << "parsing srsml..." << endl;


	// Read the xml file into a vector
	ifstream theFile ("gastrectomy.xml");
	vector<char> buffer((istreambuf_iterator<char>(theFile)), istreambuf_iterator<char>());
	buffer.push_back('\0');
	// Parse the buffer using the xml file parsing library into doc
	doc.parse<0>(&buffer[0]);
	// Find our root node
	cout << "parsing a root element" << endl;
	root_node = doc.first_node("srsml");

	int size = strlen((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("name"))->value());
	int size2 = strlen((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("type"))->value());

	// variables for malloc
	elements=(char*) malloc(size+1);
	elements2=(char*) malloc(size2+1);

	strcpy ((char*)elements,(char*)((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("name"))->value()));
	strcpy ((char*)elements2,(char*)((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("type"))->value()));

	// variables for string
	str_elements.assign((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("name"))->value());
	str_elements2.assign((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("type"))->value());

	// Iterate over the vessels
	if (root_node){
		cout << "if there is a root element" << endl;
		for (xml_node<> * models_node = root_node->first_node("models"); models_node!=NULL; models_node = models_node->next_sibling())
		{
			cout << "here is in the model for loop" << endl;
			for (xml_node<> * vessels_node = models_node->first_node("vessels"); vessels_node!=NULL; vessels_node = vessels_node->next_sibling())
			{
				cout << "here is in the vessels for loop" << endl;
				printf("I have visited in. ");//,
					// Interate over the beers
				cout << "here is before the inner for loop" << endl;
				for(xml_node<> * vessel_node = vessels_node->first_node("vessel"); vessel_node; vessel_node = vessel_node->next_sibling())
				{
					printf("On, I tried their %s which is a %s. ",
							vessel_node->first_attribute("name")->value(),
							vessel_node->first_attribute("type")->value());
				}
				cout << endl;
			}
		}
	}
}
开发者ID:sunghee,项目名称:SRSdemo-dev,代码行数:53,代码来源:SRSdemo-dev.cpp

示例14: add_to_toc

void add_to_toc(int level, xml_node<char> *title, xml_attribute<char> *id, bool not_numbered)
{
    char *style_class;
    char *fulltitle = doc.allocate_string(0, title->value_size() + 100);
    if (level == 0)
    {
        style_class = "toc1";
        if (not_numbered)
        {
            sprintf(fulltitle, title->value());
        }
        else
        {
            sprintf(fulltitle, "%i. %s", ++numbering[0], title->value());
            numbering[1] = 0;
            numbering[2] = 0;
        }
    }
    else if (level == 1)
    {
        style_class = "toc2";
        if (not_numbered)
        {
            sprintf(fulltitle, title->value());
        }
        else
        {
            sprintf(fulltitle, "%i.%i %s", numbering[0], ++numbering[1], title->value());
            numbering[2] = 0;
        }
    }
    else if (level == 2)
    {
        style_class = "toc3";
        if (not_numbered)
        {
            sprintf(fulltitle, title->value());
        }
        else
        {
            sprintf(fulltitle, "%i.%i.%i %s", numbering[0], numbering[1], ++numbering[2], title->value());
        }
    }
    else
        throw std::exception("Invalid TOC level");
    xml_node<char> *tocentry = doc.allocate_node(node_element, "a", fulltitle);
    char *link = doc.allocate_string(0, id->value_size() + 1);
    memcpy(link + 1, id->value(), id->value_size());
    link[0] = '#';
    tocentry->append_attribute(doc.allocate_attribute("href", link, 0, id->value_size() + 1));
    tocentry->append_attribute(doc.allocate_attribute("class", style_class));
    toc.append_node(tocentry);
    toc.append_node(doc.allocate_node(node_element, "br"));
    xml_node<char> *title_data = title->first_node();
    if (title_data)
        title->remove_node(title_data);
    title->value(fulltitle);
}
开发者ID:timniederhausen,项目名称:rapidxml,代码行数:58,代码来源:postprocessor.cpp

示例15: parse

XmlNodeRef XmlParserImp::parse(char* buffer, int bufLen, const char* rootNodeName, behaviac::string& errorString, bool isFinal)
{
    BEHAVIAC_UNUSED_VAR(bufLen);
    BEHAVIAC_UNUSED_VAR(errorString);
    BEHAVIAC_UNUSED_VAR(isFinal);

    m_parser.parse<0>(buffer);

    xml_node<>* xmlnode = m_parser.first_node(rootNodeName);

    XmlNodeRef node = cloneXmlNodeFrom(xmlnode);

    return node;
}
开发者ID:ag6ag,项目名称:behaviac,代码行数:14,代码来源:xmlparser.cpp


注:本文中的xml_document类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。