コード例 #1
0
EXPORT_C void CXEDomEx::SaveExampleL()
{
	RXmlEngDocument document;
	TBuf<KFilePathSize> filepath(iDrive);
	_LIT(KFilename,"\\xedomexample\\input\\XML_parsing_001.xml");
	filepath.Append(KFilename);
	TFileName srcFileName(filepath);
		
	// Need to have a document tree for saving it
    // One way is get a parsed document
	document = iDomParser.ParseFileL(srcFileName);
	CleanupClosePushL(document); 
	// The document can be modified now ...
	
    //Save it to a file
	TBuf<KFilePathSize> filepath2(iDrive);
	_LIT(KFilename2, "\\xedomexample\\output\\XML_save_file.xml");
	filepath2.Append(KFilename2);
	document.SaveL(filepath2); // The API to save (serialize) the document onto a file

	//Save to a buffer
	_LIT8(encoding,"UTF-8");
	TXmlEngSerializationOptions options(0, encoding);
	RBuf8 buffer;
	CleanupClosePushL(buffer);
	
	// The API to save (serialize) the document onto a buffer
	// It can take different serialization options
	document.SaveL( buffer, document, options); 
	                                               
	CleanupStack::PopAndDestroy(); //buffer
	CleanupStack::PopAndDestroy(); //document
}