Doubt about using XML to store data

Hi guys, I’m new to game development.

I have a question, is is common to use XML files to store some data, say, characters’ properties or enemy information ?

If so, then do I need to store those information for later reference when initializing a game scene ?

Thanks !

Hi Yifeng Wu,

yes, you can use XML files in your project to save game data. You can use pugixml library with cocos2d-x to work with XML files.

If you have an XML and you only need to read this file you only need to copy into Resource folder and include a reference into your project.

If you game are going to generate XML files to store game data, you will need to safe into a specific device folder. If you are building a multiplatform game remember that each device has its own internal folder structure to store files, so when you generate the XML you need to distinguish between devices and safe internally in the correct folder.

In Android devices every installed app has a folder under /data/data folder so if you want to safe the file example.xml you need to safe into the path /data/data/ + start activity package name + file/

Example: “/data/data/youcompany.android/files/example.xml”

In Windows there are not problem, you can safe anywhere if you have the appropriate folder permissions.

In iOS devices each app have its own folder structure, you need to safe inside Documents folder into app folder structure.

I hope you find it useful….!

José Olmos Martínez wrote:

Hi Yifeng Wu,
>
yes, you can use XML files in your project to save game data. You can use pugixml library with cocos2d-x to work with XML files.
>
If you have an XML and you only need to read this file you only need to copy into Resource folder and include a reference into your project.
>
If you game are going to generate XML files to store game data, you will need to safe into a specific device folder. If you are building a multiplatform game remember that each device has its own internal folder structure to store files, so when you generate the XML you need to distinguish between devices and safe internally in the correct folder.
>
In Android devices every installed app has a folder under /data/data folder so if you want to safe the file example.xml you need to safe into the path /data/data/ + start activity package name + file/
>
Example: “/data/data/youcompany.android/files/example.xml”
>
In Windows there are not problem, you can safe anywhere if you have the appropriate folder permissions.
>
In iOS devices each app have its own folder structure, you need to safe inside Documents folder into app folder structure.
>
>
I hope you find it useful….!

Pugixml works great, thanks a lot !