Beispiel #1
0
void CServerBrowser::RefreshFromFile( const char * szFile )
{
	// Does the file not exist?
	if( !SharedUtility::Exists( szFile ) )
		return;

	// Create the xml file instance
	CXML * pFile = new CXML( szFile );

	// Get the root node
	CXMLNode * pRootNode = pFile->GetRootNode();

	// Is the root node valid?
	if( pRootNode )
	{
		//
		String strBuffer;
		CXMLNode * pCurrentNode = NULL;
		unsigned int uiChildCount = pRootNode->GetChildCount();

		// Loop over each node
		for( unsigned int i = 0; i < uiChildCount; i++ )
		{
			// Get the current node
			pCurrentNode = pRootNode->GetNode( i );

			// Is the current node invalid?
			if( !pCurrentNode )
				continue;

			// Is this an invalid node?
			if( strcmp( pCurrentNode->GetName(), "server" ) )
				continue;

			// Append the node value to our main string
			strBuffer += String( "%s|", pCurrentNode->GetValue() );
		}

		// Process the buffer with the masterlist handler
		Event_MasterListQueryHandler( strBuffer.split( '|' ) );
	}

	// Close the xml file
	pFile->Save();

	// Destroy the xml file instance
	SAFE_DELETE( pFile );
}