XML as opposed to text files...
Hi everyone...
The last week or so I''ve been banging my head on my keyboard (sometimes literally) trying to get the data in my text files to populate into my struct arrays... Everytime I fixed one problem 2 more would pop up...
Grrr...I''m getting a migrane just thinking about it...
So I''ve done some research and I ran across the idea of using XML to store my data. From what I''ve read so far it seems like this could be my golden goose (so to speak), and help me out drastically.
My question is...Before I go all out and start researching XML, I wanted to know if anyone out there had any info they could pass my way...
Thanks in advance...
I been interested in that idea too. To me it definatly makes much sence to use XML for that purpose.
You would definatly need an XML parser that is implemented in some library. There are open source XML libraries out there to provide that support but i had not tried any of them out.
You would definatly need an XML parser that is implemented in some library. There are open source XML libraries out there to provide that support but i had not tried any of them out.
May 16, 2001 11:18 AM
if the data is hierarchical, then XML might be the ideal choice. Otherwise you might try using an .INI file or the system registry (depending upon platform).
Actually XML is a text format. I thought about doing an XML based dialogue engine since a special XML DTD could give the rules of a conversation.
All XML (or SGML
) does is describe your data. THis is best shown with an example.
If you looked at the first file, you might not know that what is going on. By looking at the second file, its pretty obvious you are looking at the description of a guy and know a few things about him.
To put this in your game you will need a XML parser, although writing your own wouldn''t be to hard, it just would be a lot of unnecessary work.
I would definitely take a look at XML, if not just learn about XML.
All XML (or SGML
![](smile.gif)
|
If you looked at the first file, you might not know that what is going on. By looking at the second file, its pretty obvious you are looking at the description of a guy and know a few things about him.
To put this in your game you will need a XML parser, although writing your own wouldn''t be to hard, it just would be a lot of unnecessary work.
I would definitely take a look at XML, if not just learn about XML.
Thanks for all the responses so far guys...
But I have another question to throw at you...Everyone keeps talking about needing a XML parser. Could someone please go into a little detail about where I could get one (download or what not) and how I''d implement XML into a windows C++ coded game.
Again...thanks in advance
But I have another question to throw at you...Everyone keeps talking about needing a XML parser. Could someone please go into a little detail about where I could get one (download or what not) and how I''d implement XML into a windows C++ coded game.
Again...thanks in advance
![](smile.gif)
Don''t use XML for the sake of using XML, it''s a waste of resources that could be used more effectively in other parts of your project.
Sure there are some reasons to use XML, but that earlier example is a bad one. You could have just as easily added tags to the first example of the two.
About the only reason I can think of to use XML in a game is to make it easy for your users or developers/map-makers/etc to modify stats without you having to write a tool for it, but again, you can do it just as easily with another text format that doesn''t require a bloated parser linked to your project ; )
G''luck,
-Alamar
Sure there are some reasons to use XML, but that earlier example is a bad one. You could have just as easily added tags to the first example of the two.
About the only reason I can think of to use XML in a game is to make it easy for your users or developers/map-makers/etc to modify stats without you having to write a tool for it, but again, you can do it just as easily with another text format that doesn''t require a bloated parser linked to your project ; )
G''luck,
-Alamar
I think a problem with using XML is that file sizes would shoot through the roof. I mean, rather than having the armor stat just listed as 7 or whatever, you have
Which is an additional 15 bytes. Now say you have that many bytes for each integer in a 10 meg data file, and you can see how massive the file would get...
I guess I don''t see the reason you can''t just define a compact, binary file format and stick to that.
Anthracks
|
Which is an additional 15 bytes. Now say you have that many bytes for each integer in a 10 meg data file, and you can see how massive the file would get...
I guess I don''t see the reason you can''t just define a compact, binary file format and stick to that.
Anthracks
About the idea of using the system registry mentioned earlier:
DON''T EVER DO THAT! The registry is probably the WORST place to store persistent data. The registry (each and every) is NOT the system-wide data disposal facility. Bad enough the freaks at Micro$(-censored-) didn''t realize when they started using one. Don''t make that mistake.
About XML:
As long as you want to transfer relatively small amounts of data over a heterogenous network, it''s about as good a thing as you might get whan it comes to simplicity (you have to understand the API, though... and the java API is one big bad bitch to use), but as soon as you start having larger amounts of data, I''d say you try writing your own protocol. Convert everything to network byte order if necessary.
DON''T EVER DO THAT! The registry is probably the WORST place to store persistent data. The registry (each and every) is NOT the system-wide data disposal facility. Bad enough the freaks at Micro$(-censored-) didn''t realize when they started using one. Don''t make that mistake.
About XML:
As long as you want to transfer relatively small amounts of data over a heterogenous network, it''s about as good a thing as you might get whan it comes to simplicity (you have to understand the API, though... and the java API is one big bad bitch to use), but as soon as you start having larger amounts of data, I''d say you try writing your own protocol. Convert everything to network byte order if necessary.
Actually I found a site that makes me think even more in the positive about using XML.
http://www.firstobject.com/markup.htm
Check it out and post what you think...
http://www.firstobject.com/markup.htm
Check it out and post what you think...
Some of the benefits of using XML:
-The parser is already done for you (MS has a few for windows, I''d suggest SAX2 for large files)
-Easy to read
-Object Oriented (so there should be little/no work in translating your data files to game objects)
-It''s structured. (If you''re going to use text, then for your own sanity use structured text of some kind.)
-Handles large size better: Imagine you''re looking for some data about a monster, and it''s in the 100th MB or so of your data file. W/o a tagged structure you have to parse a hell of a lot of data to find the monster you''re looking for. In XML, you iterate through the "< Monsters >" tag, looking at the names. If it''s not the one you''re looking for you skip all the data in that tag and move onto the next < Monster > tag...so you''ve read a minimal amount of data.
The obvious dis-advantage is the size of the tagged text. If you''re using text to begin with then size probably isn''t your largest concern. You could compress the text XML to a binary format if you want to reduce the size, but files would have to be decompressed into memory...which makes large data files a pain.
I suggest using an external object serializer, most have 2 formats: XML and Binary. You can just point the serializer to a file and it''ll write out the object in a binary format, to load it up you just point it to the file and load. I use the built in one for VB.NET, I don''t know of any others off the top of my head, but I''m sure they are out there.
Epolevne
-The parser is already done for you (MS has a few for windows, I''d suggest SAX2 for large files)
-Easy to read
-Object Oriented (so there should be little/no work in translating your data files to game objects)
-It''s structured. (If you''re going to use text, then for your own sanity use structured text of some kind.)
-Handles large size better: Imagine you''re looking for some data about a monster, and it''s in the 100th MB or so of your data file. W/o a tagged structure you have to parse a hell of a lot of data to find the monster you''re looking for. In XML, you iterate through the "< Monsters >" tag, looking at the names. If it''s not the one you''re looking for you skip all the data in that tag and move onto the next < Monster > tag...so you''ve read a minimal amount of data.
The obvious dis-advantage is the size of the tagged text. If you''re using text to begin with then size probably isn''t your largest concern. You could compress the text XML to a binary format if you want to reduce the size, but files would have to be decompressed into memory...which makes large data files a pain.
I suggest using an external object serializer, most have 2 formats: XML and Binary. You can just point the serializer to a file and it''ll write out the object in a binary format, to load it up you just point it to the file and load. I use the built in one for VB.NET, I don''t know of any others off the top of my head, but I''m sure they are out there.
Epolevne
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement