Jump to content

xml basic format/style problem


peliman

Recommended Posts

Hi! I'm making php program which saves automatically game stats. I have thought .xml would be right format because javascript can read it.The problem is that it should be easy to navigate. The stats will be saved every day, so easiest way to navigate would be by date. --year 2014----month 1------day 1---------player 1---------player 2etc. ^How should I write that in .xml? Or is .xml totally wrong format to do that?

<year2014>...</year2014><year2013>...</year2013>

^I have understood that it isn't way to do it. Same basic elements should have same name.

<year id=2014>...</year>

^Is id right way to do it?

 

Thanks in advance :)

Edited by peliman
Link to comment
Share on other sites

Here's an example:

<gameStats>    <gamer>        <date>           <year>2014</year>           <month>1</month>           <day>1</day>       </date>       <player>1</player>    </gamer></gameStats>
Edited by L8V2L
Link to comment
Share on other sites

xml is making your own tag, you can shorten iit down. I just gave you an example of what is said to be the best way to do it. What langauge do you prefer, what programing do you practice in?

Edited by L8V2L
Link to comment
Share on other sites

I'm using php and javascript. I wouldn't use .xml if javascript could read data from other file format.

 

Using your way to save data, there would be thousands of blocks data without any order. Finding specific data would be slow. For instance searching one block as below. There is 2 possible situation for year, 12 for month, 32 for day, 4 for gamemode, 3 for faction and 20 for rank.

Day: 3.6.2014Gamemode: NormalFaction: TerroristRank: 5

If it was arranged, finding data would be fast. There would be fewer options.

Server should only look 73 different situation. If they weren't arranged, it would be 184320. Arranged is more than 25x faster.

 

If it isn't possible to arranged data by date in .xml, should I use folders and many .xml files to make it arranged?

Edited by peliman
Link to comment
Share on other sites

Have you consider JSON?

"use strict";var gameStats = {       player1date:[          {year:2014,            month:1,            day:1}       ]}gameStats.player1date[0].year;//2014
Edited by L8V2L
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...