Jump to content
peliman

xml basic format/style problem

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Hmm... finding data there would be slow. Server should read every line to find the right day. Treeview by date would make it fast and easy to use.Is there any proper way to do it?

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...