I would suggest using the
SimpleXML for XML manipulation. I am not extremely familiar with it myself, but in PHP using a library to manipulate XML is a must, since parsing large text files manually is far too slow for such a core aspect of a game as a map system.
While I don't know exactly how you would do that with SimpleXML, it child value manipulation is a very basic function so it is likely one of the first couple of things you would learn in the SimpleXML section of the PHP manual.
EDIT: For a fairly simple map XML system, however, I would have to think it may be better off in the database. If you store the XML in the database, you will just be adding another layer of translation to each access, and if you keep them as text files, you will be relying on rapidly opening and closing many files in the file system, which can begin to bog down any OS. XML is not at its most useful for simply storing sets of data like:
Code: Select all
<map>
<tile>
<x_coord>3</x_coord>
<y_coord>4</y_coord>
<type>grass</type>
</tile>
</map>
While I realize this may just be an example and your actual schema may be far more complex, XML is really used at its best to represent interaction of data within their hierarchy (ie, when the data client must have the hierarchy along with hierarchy attributes to properly process it) and of course for data files that are going to be open and usable by other systems (which your maps probably won't be). Otherwise, "list encapsulation" styles of XML that can easily be represented by columns and rows in the database are better to be held there without XML. RDBs are optimized and optimized and optimized again for lightning fast threaded data access and it is hard to beat that with either the file system (XML files) or by adding more work for PHP to do (XML in the database). You would need to ensure you have a specific need for XML before you make it a core aspect of your design.