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


C++ XML::Save方法代码示例

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


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

示例1: SaveXML

void ProcessController::SaveXML()
{
	string filename = m_Filename+".xml";

	XML* xml = new XML(filename.c_str()); 
	XMLElement* e = xml->GetRootElement();
	SaveXML(e);
	if (xml->IntegrityTest())
		xml->Save(); // Saves back to file
	delete xml;
}
开发者ID:,项目名称:,代码行数:11,代码来源:

示例2: save

bool XMLfile::save(Object* pObj,const char *file) //saves the XML file created with the object
{
		// Create the XML FILE or if it already exists, it will be overwritten

	XML* xml = new XML(file);
	XMLElement* root = xml->GetRootElement();

	string className = pObj->getClassName();
	XMLElement* obj_xml=new XMLElement (root,className.c_str());

	pObj->writeToXML(obj_xml);//execute the writing process XML
	pElem.push_back(obj_xml);//save every XMLElements_Objects in pElem

	root->AddElement(obj_xml);
	xml->Save();

	return true;

}
开发者ID:drodri,项目名称:MRCore,代码行数:19,代码来源:xmlfile.cpp

示例3: main

int main()
{
    FILE *rFile = fopen("Parsefile.txt", "w");
    FILE *bFile = fopen("Samplefile.bin", "rb");
    field fd = parseFieldStructure();

    fseek (bFile, 0, SEEK_END);
    long fSize = ftell (bFile);
    fseek (bFile, 0, SEEK_SET);
	BYTE *buffer = new BYTE[fSize];
	fread(buffer, fSize, 1, bFile);

	int numRec = fSize / fd.totBytes;
    int fieldIdx = 0, fieldIncIdx = 0, intPosIdx = 0, strIdx = 0;
    int fInt = 0;
    char fStr[255];
    bool typeInt = false;

    XML* xml = new XML();
	xml->LoadText("<data></data>");
    XMLElement* root = xml->GetRootElement();
	XMLElement* record[numRec];
	XMLElement* fields[115 * numRec];

    for (int recIdx = 0; recIdx < numRec; recIdx++) {
        record[recIdx] = new XMLElement(root, "record");
        root->InsertElement(recIdx, record[recIdx]);
        bytesToIntger(fStr, recIdx + 1);
        record[recIdx]->AddVariable("id", fStr);

        for (int xmlIdx = 115 * recIdx; xmlIdx < (1 + recIdx) * 115; xmlIdx++) {
            fields[xmlIdx] = new XMLElement(record[recIdx], "field");
            record[recIdx]->InsertElement(xmlIdx, fields[xmlIdx]);
        }
    }

    int xmlIdx = 0;

    for (int idx = 0; idx <= fSize - 1; idx++)
    {
        if(idx >= fieldIncIdx) {

            if(typeInt) {
                bytesToIntger(fStr, fInt);
            } else {
                bytesToStr(fStr, strIdx);
            }

            if(fieldIdx > 0) {
                fields[xmlIdx - 1]->AddVariable(fd.name[fieldIdx - 1], fStr);
            }
            else if(idx != 0) {
                fields[xmlIdx - 1]->AddVariable(fd.name[114], fStr);
            }

            xmlIdx++;
            typeInt = fd.type[fieldIdx] == 'I';

            fprintf(rFile, "%s", fStr);
            fprintf(rFile, "\t");

            fieldIncIdx += fd.bytes[fieldIdx];
            fieldIdx = fieldIdx < 114 ? fieldIdx + 1 : 0;
            if (fieldIdx == 0)
                fprintf(rFile, "\n");
        }

        if(buffer[idx] == 0xe9) {
            fieldIncIdx++;
        } else if(typeInt) {
            fInt <<= 8;
            fInt = (fInt | buffer[idx]);
        } else if (buffer[idx] > 0x1f && buffer[idx] < 0x7f) {
            fStr[strIdx++] = buffer[idx];
        }
    }

    xml->Save("XMLfile.xml");
    fclose(rFile);
    fclose(bFile);

    /* And now we can search for a attrinute
       like subscriber_no in our xml-file. */

    OpenXML("XMLfile.xml", "subscriber_no");

    return 0;
}
开发者ID:Megnus,项目名称:BinaryFileParser,代码行数:88,代码来源:main.cpp

示例4: main


//.........这里部分代码省略.........
	 {
	 // Add some variables
	 el->AddVariable(new XMLVariable("somename","somevalue"));
	 // Note that the new XMLVariable we added is now owned by el

	 // Export only this element
	 el->Export(stdout,1,XML_SAVE_MODE_ZERO); // this prints <testel somename="somevalue"/>
	 }

 // Find an element that may not exist, get its variable X that may not exist, get 
 // a default value of 0
 int v = r->FindElementZ("elx",true)->FindVariableZ("varx",true)->GetValueInt();
 // Set it to 5, set some more
 r->FindElementZ("elx",true)->FindVariableZ("varx",true)->SetValueInt(5);
 r->FindElementZ("elx",true)->FindVariableZ("varx2",true)->SetValueInt(10);
 // Printout it
 // This would print: <elx varx="5" varx2="10"/>
 r->FindElementZ("elx",true)->Export(stdout,1,XML_SAVE_MODE_ZERO);

 // Remove the var we just added
 int ix = r->FindElement("elx");
 if (ix != -1)
	 r->RemoveVariable(ix);

 // Other XMLElement functions
 r->Copy(); // Copy entire thing to windows clipboard

 XMLElement* nP = XML::Paste();
 if (nP)
	 {
	 fprintf(stdout,"Successfully copy/paste from clipboard.\r\n");
	 delete nP; // This nP is not owned by x, so we must delete it!
	 }

 // Get a duplicate
 XMLElement* dup = r->Duplicate();
 if (dup)
	 delete dup;

 // Add a comment to the root element
 int nComments = r->AddComment(new XMLComment(0,0,"Nice comment"),0); 

 // Add same comment to the header
 x->GetHeader()->AddComment(x->GetRootElement()->GetComments()[nComments - 1]->Duplicate(),0);

 // Use XMLSetString, XMLSetBinaryData
 XMLSetString("El1\\El2\\El3","var1","x",0,x);

 RECT rc = {0};
 GetWindowRect(GetDesktopWindow(),&rc);
 XMLSetBinaryData("El1\\El2\\El3","var2",(char*)&rc,sizeof(rc),0,x);

 // Get again
 RECT rc2 = {0};
 XMLGetBinaryData("El1\\El2\\El3","var2",(char*)&rc2,(char*)&rc2,sizeof(rc2),0,x);
 if (memcmp(&rc,&rc2,sizeof(rc)) != 0)
	 fprintf(stderr,"Error in binary data transfer!\r\n");
 else
	 fprintf(stdout,"Binary data transfer OK!\r\n");

 // Import database in cdrom.mdb
 // Careful; not tested with ACCESS 2007
 /*IMPORTDBPARAMS dbp = {0};
 char f[300] = {0};
 GetCurrentDirectory(300,f);
 strcat(f,"\\cdrom.mdb");
 dbp.dbname = f;
 dbp.nTables = 1;
 dbp.provstr = 0; // use default
 IMPORTDBTABLEDATA tbl = {0};
 strcpy(tbl.name,"Collection"); // Table name in MDB
 strcpy(tbl.itemname,"v");  // Default name for out elements
 tbl.nVariables = 4; // ID , CD , Name , Comments
 char* v1[] = {"ID","CD","Name","Comments"};
 char* v2[] = {"ID","CD","Name","Comments"};
 tbl.Variables = v1;
 tbl.ReplaceVariables = v2; // In case we want different name
 dbp.Tables = &tbl;
 XMLElement* d = 0;
 d = XML::ImportDB(&dbp); 
 if (d && d->IntegrityTest())
	 {
	 d->Export(stdout,1,0);
	 delete d;
	 }
*/

 // XML object save
 // Manipulate export format
 XMLEXPORTFORMAT xf = {0};
 xf.UseSpace = true;
 xf.nId = 2;
 x->SetExportFormatting(&xf);
 if (x->Save(f2) == 1)
	fprintf(stdout,"%s saved.\r\n",f2);

 // XML object bye bye
 delete x;
    std::cin.get();
 }
开发者ID:visusnet,项目名称:Blobby-Warriors,代码行数:101,代码来源:xmltest.cpp


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