示例#1
0
BOOL CPlayerWnd::SaveXML(CXMLElement* pXML)
{
	ASSERT( pXML != NULL );
	
	CFile pFile;
	if ( ! pFile.Open( _T("Xhistory.xml"), CFile::modeWrite|CFile::modeCreate ) ) return FALSE;
	
	CXMLElement* pParent = LoadXML( pXML->GetName() );
	if ( ! pParent ) pParent = CreateXML();
	
	pParent->GetElementByName( pXML->GetName() )->Delete();
	pParent->AddElement( pXML );
	
	CString strXML;
	strXML = pParent->ToString( TRUE, TRUE );
	
	pFile.Write( (LPCSTR)strXML, strXML.GetLength() );
	
	pFile.Close();
	pXML->Detach();
	pParent->Delete();
	
	return TRUE;
}