• Advertisement
Sign in to follow this  

XML

This topic is 4253 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
Quote:
Original post by Zahlman
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.


I like this advice!

On topic: one thing XML is used for is to make it a bit more easy for games to be moddable. In civilization 4 for example, you can change all kinds of things from unit statistics to interface to the in-game text in XML. Being in text form, this makes it easier for modders to understand and use.
This article on gamedev is about that, the following snippet from it is very clear:
<invadersgame>
<level>
<!-- here's where we declare the aliens -->
<alien xpos="0" ypos="100" color="red" points="10" />
<alien xpos="100" ypos="100" color="green" points="10" />
<alien xpos="200" ypos="100" color="blue" points="10" />
</level>
</invadersgame>

Share this post


Link to post
Share on other sites
Quote:
Original post by Nypyren
@ 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)


Ahh but thats assuming you always have tool support. What happens when the game play team makes a new data format they need read into the game. Perhaps, its a camera cutscene system they just wrote. If they left it in a binary format they would have to write the build program their self. If they left it in XML they could, for the time being until tool support is there, just edit the XML directly to get game play up and running.

This prevents a stall while waiting for tool support.

Quote:
Allowing people to do a text merge of asset intermediate data is a bad idea.
I meant a custom merge program, that based on the format allows an artist to view which file he'd like to pick. If the merge program is specific to the asset type then allowing an artist to use it is ok.

Share this post


Link to post
Share on other sites
I think XML is a mistake.

I mean, it's abused and ill-used tool which was made by people who didn't really know enough to do such thing and marketted it well. It's a great example about situation where little knowledge about computer science instead of knowing just how to engineer, would been help a lot to make much more capable language than what XML is.

What's bad with XML? Well, it's not generic enough, and it has very complex parsing rules, especially if we consider it has a unconvenient and ugly way to represent strings straight with five unnecessary control character.

I'd propose better language look something like this:

<invadersgame
<level "revenge of the galagans!"
tutorial="""destroy every fighter and prevent enemies breaching
the planet barrier."""
<aliens <0 100 red>
<100 100 green points=20>
<200 100 blue points=5>>>>

Share this post


Link to post
Share on other sites
Some time in the past, there was a interesting "heated debate" between lisp and XML. A little searching and I didn't find it [sad]

Share this post


Link to post
Share on other sites
Quote:
Original post by Boder
Some time in the past, there was a interesting "heated debate" between lisp and XML. A little searching and I didn't find it [sad]


**This thread is so official it needs to be linkified**
One Language to rule them all

here's a link: http://www.gamedev.net/community/forums/topic.asp?topic_id=137558
there's some more give an hour... hopefully search isn't broken.

note: there's a FEW heated debates about XML and Lisp..
edit: had to link Lisp is King

Share this post


Link to post
Share on other sites
Quote:
Original post by Cheery
What's bad with XML? Well, it's not generic enough, and it has very complex parsing rules, especially if we consider it has a unconvenient and ugly way to represent strings straight with five unnecessary control character.


???

XML is very generic, and there is no need to worry about the complex (?) parsing rules because the parsing is done for you. And you don't have to "represent strings straight with five unnecessary control character" and so what if it is "ugly".

The nice things about XML are:
  • it is simple,
  • it is flexible,
  • it is powerful,
  • and it comes with a parser.


Some drawbacks are:
  • it doesn't support binary very well,
  • files can get huge and take a long time to process,
  • it might be overkill for very simple data.

Share this post


Link to post
Share on other sites
JohnBolton, yes, it'd be that for me too if lisp wouldn't exist.

But because it exists, I prefer it. Mostly because it works also as thinking and programming language. The homoiconic form gives it the power and the thing what XML has not; You are unable to think in XML or write programs with it (not considering embedded algol -style syntax some ppl seems to prefer).

Lisp is simpler than XML, that makes it more flexible and more powerful. Simpler means also that it is more generic than XML.

And as extra: parser is so simple you can write it yourself, and it can be highly optimized, that means even large chunks of information can be processed in decent time. Even better: if you have lisp enviroment under, you can use the highly optimized reader in itself, because lisp reader can be used for representing any data.

You see? You have very simple syntax in lisp!
( == opens a parenthesis.
) == closes it (somewhere this is just a special identifier).
sequence of 0-9 == number
" following " == string, this can go multi-line
other sequences of letters which aren't invalid == interned identifier.
noninvalid characters following : == keyword identifier.

Of course there's all those else macro characters, but I gues it is more for making it fun to program. You could do that with pure data as well. This is only one thing which makes lisp best.

If you need examples about it's flexibility, tell me. ;)

Share this post


Link to post
Share on other sites
Quote:
Original post by Alpha_ProgDes
Quote:
Original post by Boder
Some time in the past, there was a interesting "heated debate" between lisp and XML. A little searching and I didn't find it [sad]


**This thread is so official it needs to be linkified**
One Language to rule them all

here's a link: http://www.gamedev.net/community/forums/topic.asp?topic_id=137558
there's some more give an hour... hopefully search isn't broken.

note: there's a FEW heated debates about XML and Lisp..
edit: had to link Lisp is King


Have you managed to find the debate between Lisp and XML? I'd be interested in doing some research into it and see if it would be worth any development time.

- Dave

Share this post


Link to post
Share on other sites
Quote:
Original post by ph33r
Have you managed to find the debate between Lisp and XML? I'd be interested in doing some research into it and see if it would be worth any development time.

- Dave


here's something:
Code is data....

I don't know what they've been talking here before, but personally I'd prefer you to look further into Lisp. I found my virtues and enlightened in computer science; It told me where do I find my super geek from. After understanding the philosophy behind Lisp, I've been feeling like a superman with computers. I feel I can do anything I want!

Share this post


Link to post
Share on other sites
Quote:
Original post by ph33r
Quote:
Original post by Alpha_ProgDes
Quote:
Original post by Boder
Some time in the past, there was a interesting "heated debate" between lisp and XML. A little searching and I didn't find it [sad]


**This thread is so official it needs to be linkified**
One Language to rule them all

here's a link: http://www.gamedev.net/community/forums/topic.asp?topic_id=137558
there's some more give an hour... hopefully search isn't broken.

note: there's a FEW heated debates about XML and Lisp..
edit: had to link Lisp is King


Have you managed to find the debate between Lisp and XML? I'd be interested in doing some research into it and see if it would be worth any development time.

- Dave

Unfortunately, my Google-Fu is still at grasshopper status. I know there's been at least 5 Lisp vs. XML threads, but I can only find those 2. [sad]

Share this post


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

  • Advertisement