Jump to content
  • Advertisement
Sign in to follow this  
Kenny77

XML

This topic is 4520 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What is XML and how is it used in games? I noticed while looking through files of some created programs they included XML files.

Share this post


Link to post
Share on other sites
Advertisement
XML stands for "Extensible Mark-Up Language." Specifically, it isn't anything but a form of grammar, to put it simple. It's a way to format documents, set by a standard, to make them organized, easier to read, parsable, etc... It's format is almost exactly like HTML's, and it can be read in Notepad. I recommend you Google it a little.

Share this post


Link to post
Share on other sites
XML is a markup language similar to HTML.

But, XML can be used to create a more structured, custom representation to the file. There are libraries that allow you to read and write XML files quite easily.

XML is used in games probably primarily to store custom option in the game
e.g. Screen Size, Video Quality, etc...

It could also be used to store information about levels or saved games.

It could be used for many things, that is just a few options.

For more information check this out.

I hope that helps.

Share this post


Link to post
Share on other sites
I'm not quite following, but this is an example:

 
- <city tileset="config files\tileset.xml">
<road x1="6" y1="6" x2="6" y2="19" />
<road x1="6" y1="6" x2="24" y2="6" />
<road x1="24" y1="6" x2="24" y2="11" />
<road x1="6" y1="11" x2="25" y2="11" />
<road x1="25" y1="11" x2="25" y2="16" />
<road x1="6" y1="16" x2="25" y2="16" />
<road x1="24" y1="16" x2="24" y2="23" />
<road x1="13" y1="22" x2="16" y2="22" />
<road x1="16" y1="23" x2="24" y2="23" />
<road x1="16" y1="23" x2="16" y2="16" />
<road x1="13" y1="22" x2="13" y2="6" />
<road x1="6" y1="19" x2="13" y2="19" />
<road x1="10" y1="16" x2="10" y2="11" />
<road x1="6" y1="13" x2="10" y2="13" />
<road x1="6" y1="8" x2="13" y2="8" />
<road x1="18" y1="16" x2="18" y2="6" />
<road x1="21" y1="23" x2="21" y2="16" />
<road x1="21" y1="11" x2="21" y2="6" />

Share this post


Link to post
Share on other sites
It's just a way to store intermediate data before loaded into a game. Most games store there data in XML because its human readable. Then a tool takes the XML file parses it and turns the human readable format into a binary format thats optimized for the target platform of the game, whether it be ps3 or PC.

You can see from the file you pasted that its some sort of location of road tiles. It has a list of road pieces with the extents of the rectangle it covers<minx,miny>, <maxx, maxy>. I'm assuming that the game will parse this list and see those 18 road pieces and place them in the level at its location based on the bounding box specified for each line.

Really, its just all about having an intermediate human readable format. It's not the final set of data that ends up being inside the game

Share this post


Link to post
Share on other sites
Avoid using XML anywhere that will affect performance. Never parse text when you can use binary storage. Only use XML for human-readability-required things or for data exchange between companies that can't wrap their minds around data structures (which can be surprisingly many).

I've used many non-game apps that decided to use XML for ALL data storage, and their performance suffers greatly because of this (I'm specifically thinking of Trillian).

Share this post


Link to post
Share on other sites
Quote:
Original post by Nypyren
Avoid using XML anywhere that will affect performance. Never parse text when you can use binary storage. Only use XML for human-readability-required things or for data exchange between companies that can't wrap their minds around data structures (which can be surprisingly many).

I've used many non-game apps that decided to use XML for ALL data storage, and their performance suffers greatly because of this (I'm specifically thinking of Trillian).


I'm going to second this. Working with text instead of binary can hit your performance harder than you think.

Share this post


Link to post
Share on other sites
Quote:
Original post by Nypyren
Avoid using XML anywhere that will affect performance. Never parse text when you can use binary storage. Only use XML for human-readability-required things or for data exchange between companies that can't wrap their minds around data structures (which can be surprisingly many).

I've used many non-game apps that decided to use XML for ALL data storage, and their performance suffers greatly because of this (I'm specifically thinking of Trillian).


Woah, XML is great as an intermediate format, meaning it doesn't get loaded into the final executable. Most game production pipelines go like this

1) natural data format(photoshop .psd, maya file, and game levels)
- EXPORTS to
2) XML intermediate format or anoter form of a database
- BUILDS to
3) target platform specific binaries(PS3, PSP, PC, XBOX...)
- PACKAGES to
4) compressed packfile

The compressed packfile is what finally gets loaded into the game. Though, removing #2 will cripple the pipeline when you want to start doing content control and custom merge programs. Really, 3 feeds from the intermediate format and should not have to re-export the data for each target platform.

Hope that gives a clear overview of the tools pipeline for most studios.

- Dave

Share this post


Link to post
Share on other sites
@ ph33r: Totally agreed. I just posted that because we're in the beginner's forum ;)

[Edit ... on second thought...]

You can drastically speed up an asset pipeline by using a binary intermediate format. You just have to put experienced people on the pipeline tools (read: NOT THE INTERNS)

Allowing people to do a text merge of asset intermediate data is a bad idea. Artists, level designers, etc. that I've worked with wouldn't know what to do with a 3-way merge if they ever saw it. In all reality you would want to be merging the source files (which is impossible since .mb .psp, etc are binary and there aren't a lot of solutions that know how to merge those properly).

You're going to have to write a tool to do the intermediate -> per platform step anyway, so you might as well make it operate as fast as possible by using binary inputs. At my job, there's a *lot* of overhead waiting for the asset pipeline to do its grunge work, and it would be nice if this was faster than it currently is.

Share this post


Link to post
Share on other sites
Don't ask "What is X and how can I use it?" Ask "What things exist that can help me do Y?" Trust me, in the long run there will be much less pain.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!