As a personal project, I'm making an AJAX chatroom application using XML as a server-side storage, and JSON for client-side processing.
Here's how it works:
- AJAX Request gets sent to PHP using GET (chat messages/logins/logouts)
- PHP fetches/modifies the XML file on the server
- PHP encodes the XML into JSON, and sends back JSON response
- Javascript handles JSON information (chat messages/logins/logouts)
I want to eventually make this a larger-scale chatroom application. Therefore, I want to make sure it's fast and efficient.
Was this a bad design choice? In this case, is switching between XML and JSON ok, or is there a better way?
EDIT:
Two mechanisms prevent a big server load when fetching information from the server:
- An "event id" is assigned to each message/login/logout, so all that's sent back to the user is the events his client hasn't yet processed.
- When an XML file becomes too big, a new one is created.