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


C++ XMLDocument::NewElement方法代码示例

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


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

示例1:

void emu::Settings::CreateDefaultXml(char const * filename)
{
    cpumode = "interpeter-slow";
    gerenderer = "pspe4all-hal.video.OGL4";

    XMLDocument xmlDoc;

    XMLNode * pRoot = xmlDoc.NewElement("pspe4all");
    xmlDoc.InsertFirstChild(pRoot);
    XMLElement * pElement = xmlDoc.NewElement("GeneralSettings");

    XMLElement * pListElement = xmlDoc.NewElement("CpuMode");
    pListElement->SetText(cpumode.c_str());

    pElement->InsertEndChild(pListElement);

    XMLElement * pListElement2 = xmlDoc.NewElement("GeRenderer");
    pListElement2->SetText(gerenderer.c_str());

    pElement->InsertEndChild(pListElement2);

    pRoot->InsertEndChild(pElement);

    xmlDoc.SaveFile(filename);
}
开发者ID:hlide,项目名称:psce4all,代码行数:25,代码来源:emu.Settings.cpp

示例2: example_5

void example_5()
{
    printf( "XML Example 5\n" );
    
    // Test: Programmatic DOM
    // Build:
    //		<element>
    //			<!--comment-->
    //			<sub attrib="1" />
    //			<sub attrib="2" />
    //			<sub attrib="3" >& Text!</sub>
    //		<element>
    
    XMLDocument* doc = new XMLDocument();
    XMLNode* element = doc->InsertEndChild( doc->NewElement( "element" ) );
    
    XMLElement* sub[3] = { doc->NewElement( "sub" ), doc->NewElement( "sub" ), doc->NewElement( "sub" ) };
    for( int i=0; i<3; ++i ) {
        sub[i]->SetAttribute( "attrib", i );
    }
    element->InsertEndChild( sub[2] );
    XMLNode* comment = element->InsertFirstChild( doc->NewComment( "comment" ) );
    element->InsertAfterChild( comment, sub[0] );
    element->InsertAfterChild( sub[0], sub[1] );
    sub[2]->InsertFirstChild( doc->NewText( "& Text!" ));
    doc->Print();
    
    doc->SaveFile( "pretty.xml" );
    doc->SaveFile( "compact.xml", true );
    delete doc;
}
开发者ID:emonson,项目名称:tinyxml2tokenize,代码行数:31,代码来源:main.cpp

示例3: save

/*
 int m_score;
 Point2i m_offset;
 int m_cols;
 int m_rows;
 enColor map[EDIT_GRAPH_ROW][EDIT_GRAPH_COL];
 */
void GraphDataStorageXML::save(const char* path, const GraphData& data, const StageBaseData* baseData) {
    cocos2d::log("save_crazysnow map path=%s", path);
    try {
        XMLDocument doc;
        XMLDocument *myDocument = &doc;
        
        {
            XMLElement* property = myDocument->NewElement("property");
            myDocument->LinkEndChild(property);
            
            //property->SetAttribute("score", data.score);
            property->SetAttribute("cols", data.cols);
            property->SetAttribute("rows", data.rows);
        }
        {
            XMLElement* map = myDocument->NewElement("map");
            myDocument->LinkEndChild(map);
            
            for (size_t row = 0; row < data.rows; ++row)
                for (size_t col = 0; col < data.cols; ++col) {
                    char buf[200]; sprintf(buf, "%ld_%ld", row, col);
                    map->SetAttribute(buf, data.map[row][col].catgy.color);
                }
        }
        
        myDocument->SaveFile(path);
    } catch (std::string& e) {
        cocos2d::log("%s\n", e.c_str());
    }
}
开发者ID:oostudy,项目名称:CrazySnow,代码行数:37,代码来源:GraphDataStorage.cpp

示例4: newHighScore

void highscore::newHighScore(score *newHighScore)
{
    // SAVE NEW SCORE DIRECTLY INTO XML FILE
    // Load XML file
    char scoreStr[10];

    XMLDocument doc;
    XMLElement *nodeTransversal;
    doc.LoadFile("score.xml");

    // Write its child first
    XMLText *nameText = doc.NewText(newHighScore->readPlayerName().c_str());
    XMLElement *name = doc.NewElement("name");
    name->InsertEndChild(nameText);

    sprintf(scoreStr, "%d", newHighScore->readScore());
    XMLText *scoreText = doc.NewText(scoreStr);
    XMLElement *score = doc.NewElement("score");
    score->InsertEndChild(scoreText);

    // Create new node
    XMLElement* hs = doc.NewElement("hs");
    hs->InsertEndChild(name);
    hs->InsertEndChild(score);

    doc.InsertEndChild(hs);

    doc.SaveFile("score.xml");
}
开发者ID:dwipasawitra,项目名称:simple-tetris,代码行数:29,代码来源:highscores.cpp

示例5: createStorageFile

void createStorageFile(const string& path) {	
  XMLDocument doc;
  doc.SetValue("files");
  auto root = doc.NewElement("files");
  doc.LinkEndChild(root);

  int width = 42;
  fs::path current(path);
  fs::recursive_directory_iterator end;
  cout << "Go to directory iterator: " << current.string() << " -> " << endl;
  for (fs::recursive_directory_iterator item(current); item != end; ++item) {
    if (!fs::is_directory(item->status())) {
      string filename = item->path().string();	
      if ((int)filename.size()>width) {
	cout << "[file]: ..." << filename.substr(filename.size()-width) << endl;
      }
      else cout << "[file]: " << filename << endl;

      auto file = doc.NewElement("file");
      file->SetAttribute("name", filename.substr(current.string().size()).c_str());
      file->SetAttribute("last_modif", to_string(fs::last_write_time(filename)).c_str());
      root->LinkEndChild(file);
    }
  }
  
  doc.SaveFile(gStorage.c_str());
}
开发者ID:almikh,项目名称:patches-creator,代码行数:27,代码来源:patches-creator.cpp

示例6: save

void SystemSettings::save(const K::File& file) {

	XMLDocument doc;
	XMLElement* nRoot = doc.NewElement("KSynth");
	XMLElement* nSettings = doc.NewElement("Settings");

	doc.InsertFirstChild(nRoot);
	nRoot->InsertEndChild(nSettings);

	// the sound-sink
	XMLElement* nSink = doc.NewElement("SoundSink");
	nSink->SetAttribute("name", getSoundSink()->getName().c_str());
	nSettings->InsertEndChild(nSink);

	// refresh
	XMLElement* nGui = doc.NewElement("GUI");
	nSettings->InsertEndChild(nGui);
	XMLElement* nGuiRefresh = doc.NewElement("Refresh");
	nGuiRefresh->SetAttribute("ms", getGuiRefreshInterval());
	nGui->InsertEndChild(nGuiRefresh);



	doc.SaveFile( file.getAbsolutePath().c_str() );

}
开发者ID:k-a-z-u,项目名称:KSynth,代码行数:26,代码来源:SystemSettings.cpp

示例7: testPrintXML

void testPrintXML() {
	XMLDocument doc;
	XMLElement* root = doc.NewElement("root");
	XMLElement* path = doc.NewElement("status");
	XMLText* text = doc.NewText("0");
	doc.InsertEndChild(root);
	root->InsertEndChild(path);
	path->InsertEndChild(text);
	XMLPrinter printer(0, true);
	doc.Print(&printer);
	cout << printer.CStr() << endl;
}
开发者ID:koala87,项目名称:phoenix,代码行数:12,代码来源:testXML.cpp

示例8: save

void CSessionParameters::save(std::string _filename){
    XMLDocument doc;
    char buffer[300], bufferLabel[100];


    XMLElement* root = doc.NewElement("configuration");
    doc.InsertEndChild(root);
    XMLElement* tmpEle = NULL;

    for( int idx = 1; idx < MAX_NUM_OF_VIDEOS; ++idx ){
        if( filename.count(idx) == 0 || zeroOffset.count(idx) == 0 ){
            continue;
        }
        // filename
        sprintf(bufferLabel, "filename%d", idx);
        XMLElement* tmpEle = doc.NewElement(bufferLabel);
        tmpEle->InsertEndChild( doc.NewText(filename.at(idx).c_str()) );
        root->InsertEndChild(tmpEle);
        // offset
        sprintf(bufferLabel, "offset%d", idx);
        tmpEle = doc.NewElement(bufferLabel);
        sprintf(buffer, "%d", zeroOffset[idx]);
        tmpEle->InsertEndChild( doc.NewText(buffer) );
        root->InsertEndChild(tmpEle);
    }

    // persons
    if( pPersons ){
        tmpEle = doc.NewElement("persons");
        root->InsertEndChild(tmpEle);
        for( std::map<int, CPerson*>::iterator iter = pPersons->begin();
             iter != pPersons->end(); ++iter )
        {
            CPerson* tmpPerson = iter->second;
            tmpPerson->toXml(&doc, tmpEle);
        }
    }

    // time marks
    if( pTimeMarks ){
        tmpEle = doc.NewElement("timeline");
        root->InsertEndChild(tmpEle);
        for( vector<CTimeMark>::iterator iter = pTimeMarks->begin();
             iter != pTimeMarks->end(); ++iter)
        {
            iter->toXml(&doc, tmpEle);
        }
    }

    doc.SaveFile(_filename.c_str());
}
开发者ID:racamirko,项目名称:rnd_tools,代码行数:51,代码来源:CSessionParameters.cpp

示例9: create

void BasicServiceUsedList_XmlTag::create(XMLDocument& doc, XMLElement* const mobileOriginatedCall){
    XMLElement* basicServiceUsedList = doc.NewElement("basicServiceUsedList");
    XMLText* basicServiceUsedListText = doc.NewText("");
    basicServiceUsedList->LinkEndChild(basicServiceUsedListText);
    mobileOriginatedCall->LinkEndChild(basicServiceUsedList);

}
开发者ID:lalanne,项目名称:XMLMessageGenerator,代码行数:7,代码来源:BasicServiceUsedList_XmlTag.cpp

示例10: testErrMsg

void testErrMsg() {
	XMLDocument doc;
	XMLElement* root;
	XMLElement* node;
	doc.InsertEndChild(root = doc.NewElement("root"));
	root->InsertEndChild(node = doc.NewElement("status"));
	node->InsertEndChild(doc.NewText("1"));
	root->InsertEndChild(node = doc.NewElement("error"));
	node->InsertEndChild(doc.NewText("hello world"));

	XMLPrinter printer(0, true);
	doc.Print(&printer);
	cout << printer.CStr() << endl;
	cout << printer.CStrSize() << endl;
	cout << strlen(printer.CStr()) << endl;
}
开发者ID:koala87,项目名称:phoenix,代码行数:16,代码来源:testXML.cpp

示例11: vFile

bool CGBFile<GeomType, ValueType>::save(const std::string& directoryname, const std::string& fn, const Volume3d<GeomType, ValueType>& volume)
{	
	const std::string& filename = directoryname + "/" + fn;
	XMLDocument xml;
	XMLDeclaration* decl = xml.NewDeclaration();
	xml.InsertEndChild(decl);
	XMLNode* root = xml.NewElement("root");
	xml.InsertEndChild(root);

	{
		XMLElement* res = xml.NewElement(resStr.c_str());

		res->SetAttribute("x", volume.getResolutions()[0]);
		res->SetAttribute("y", volume.getResolutions()[1]);
		res->SetAttribute("z", volume.getResolutions()[2]);

		root->InsertEndChild(res);
	}

	root->InsertEndChild( create(xml, originStr, volume.getStart()) );
	root->InsertEndChild( create(xml, "length", volume.getSpace().getLengths()));

	imageFileNames.clear();
	{
		XMLElement* e = xml.NewElement("volume");

		e->SetAttribute("type", "unsigned char");
		e->SetAttribute("format", "png");

		VolumeFile vFile(directoryname);
		for (size_t i = 0; i < volume.getResolutions()[2]; ++i) {
			const auto iFile = vFile.toImageFile( "image", i, ImageFile::Type::PNG);
			XMLElement* elem = xml.NewElement("image");
			const auto& str = iFile.getFileNameIncludingPath();
			elem->SetAttribute("path", str.c_str());
			e->InsertEndChild(elem);
			imageFileNames.push_back(str);
		}

		root->InsertEndChild(e);
	}

	//for (size_t i = 0; i < )
	
	xml.SaveFile(filename.c_str());
	return true;
}
开发者ID:SatoshiMabuchi,项目名称:CrystalGraphics,代码行数:47,代码来源:CGBFile.cpp

示例12: write

void FileList::write() {
	XMLDocument doc;
	{
		XMLElement* filelist = doc.NewElement("filelist");
		filelist->SetAttribute("application", "video-organizer");
		filelist->SetAttribute("version", "1.0");
		for (unsigned i = 0; i < records.size(); i++) {
			XMLElement* record = doc.NewElement("record");
			record->SetAttribute("from", records[i].from.c_str());
			record->SetAttribute("to", records[i].to.c_str());
			record->SetAttribute("action", records[i].action);
			filelist->InsertEndChild(record);
		}
		doc.InsertEndChild(filelist);
	}
	XMLError ret = doc.SaveFile((dir + "filelist").c_str());
	if (ret) console.e("Error writing filelist: %s", ret);
}
开发者ID:JoelSjogren,项目名称:video-organizer,代码行数:18,代码来源:filelist.cpp

示例13: writeToFile

void CSettings::writeToFile() {
  XMLDocument doc;
  XMLElement *pSettingsElem = doc.NewElement("settings");
  doc.InsertEndChild(pSettingsElem);

  // Input
  XMLElement *pInput = doc.NewElement("input");
  pSettingsElem->InsertEndChild(pInput);

  pInput->SetAttribute("map_editor_button_size",
		       m_InputSettings.m_fMapEditorButtonSize);
  
  XMLElement *pInputTouch = doc.NewElement("touch");
  pInput->InsertEndChild(pInputTouch);

  pInputTouch->SetAttribute("button_size", m_InputSettings.m_fTouchButtonSize);

  // video
  XMLElement *pVideo = doc.NewElement("video");
  pSettingsElem->InsertEndChild(pVideo);
  
  pVideo->SetAttribute("hud_size", m_VideoSettings.m_fHUDSize);

  // social gaming
  XMLElement *pSocialGaming = doc.NewElement("social_gaming");
  pSettingsElem->InsertEndChild(pSocialGaming);
  
  pSocialGaming->SetAttribute("login_on_start", m_SocialGamingSettings.m_bLoginOnStart ? "true" : "false");


  // do the output
  XMLPrinter xmlprinter;
  doc.Accept(&xmlprinter);

  std::string header("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
  std::string text(xmlprinter.CStr());

  std::fstream stream;
  if (CFileManager::openFile(stream, SETTINGS_FILE_PATH, std::ofstream::out | std::ofstream::trunc)) {
    stream << header;
    stream << text;
    stream.close();
  }
}
开发者ID:ChWick,项目名称:Mencus,代码行数:44,代码来源:Settings.cpp

示例14: DumpProfilingInfo

static void DumpProfilingInfo()
{
	XMLDocument doc;
	XMLDeclaration *d = doc.NewDeclaration();

	DIVIDEND_EXIT_ERROR_ON(d== NULL, -1, "Invalid XML Declaratio");
	doc.InsertEndChild(d);

	XMLNode * tnode = doc.NewElement( "DIVIDEND" );  
	XMLNode * lnode = doc.NewElement( "LWGS" );  

	DIVIDEND_EXIT_ERROR_ON(tnode == NULL, -1, "Failed to crate a node");
	DIVIDEND_EXIT_ERROR_ON(lnode == NULL, -1, "Failed to crate a node");

	doc.InsertFirstChild(tnode);
	tnode->InsertFirstChild(lnode);

	for (unsigned i=0; i<profEventIndex; i++)
	{
		XMLElement *kElement = doc.NewElement( "Kernel" );
		XMLNode * kNode = tnode->InsertFirstChild( kElement ); 
		
		kElement->SetAttribute("id",KPI[i].kernel_id);
		
		float time = 0.0;
		
		for (unsigned j=0; j<KPI[i].idx; j++)
		{
			//clGetEventProfilingInfo(KPI[i].event[j], CL_PROFILING_COMMAND_START, sizeof(KPI[i].time_starti[j]), &(KPI[i].time_start[j]), NULL);
			//clGetEventProfilingInfo(KPI[i].event[j], CL_PROFILING_COMMAND_END, sizeof(KPI[i].time_end[j]), &(KPI[i].time_end[j]), NULL);
			time = time + (KPI[i].time_end[j] - KPI[i].time_start[j])/1000000.0;
		}

		time = time / (float) KPI[i].idx;
		
		kElement->SetAttribute("time", time);
		lnode->InsertEndChild( kElement ); 
	}

	tnode->InsertEndChild(lnode);
	doc.InsertEndChild(tnode);
	doc.SaveFile(DIVIDEND_PROF_FILE_NAME);
}
开发者ID:zwang4,项目名称:dividend,代码行数:43,代码来源:dividend_prof.cpp

示例15: main

int main(int argc,char** argv){
    XMLDocument doc;
    XMLElement* ele =  doc.NewElement("mydiv");
    doc.NewDeclaration();
    ele->SetAttribute("test",10);
    doc.InsertEndChild(ele);
    if(!doc.SaveFile("test.xml")){
        cout<<"success";
    };
    return 0;
}
开发者ID:hccde,项目名称:AlgorithmPractice,代码行数:11,代码来源:tinyxml2-test.cpp


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