View Full Version : Xml


the100thballoon
Oct 26, 2005, 07:30 PM
Anyone tried to make sense of the XML files yet? I glanced at one of them and its not too confusing, but a tutorial is definately in order. Anyone up to the challenge?

WildWeazel
Oct 26, 2005, 08:06 PM
Sig. Fourth line. Clicky. :)
I'll expand and adapt it to cover Civ when I get it. Right now it's more of a basic intro.

Chieftess
Oct 26, 2005, 09:06 PM
Ok, here's a quickie:

Think of XML like UBB code, only more structured.

You have: [.b]bold [.u]nested underline[/u] end underline [/b] end bold.
It looks like:

[.b]
[.u]
[/u]
[/b]

XML works the same way. (Look at the source in your browser -- view->source. It looks like HTML too).

You'll see something like:

<units>
<strength>5</strength>
</units>

the <strength>...</strength> field tells the game that it's the strength of the unit. If you change 5 to say, 50, you have one powerful unit!

Dom Pedro II
Oct 26, 2005, 09:31 PM
I could maaaybe whip something up.. but I'd rather somebody else did :)

WildWeazel
Oct 26, 2005, 09:36 PM
I'll take care of it when my game arrives.

@CT (or whoever): I don't suppose it would be legal for somebody to send me a piece of the xml? :hmm:

popewiz
Oct 27, 2005, 01:23 AM
Ok, I'll try to help out a little before I go to sleep. First of all, everything we'll be modding will be in the folder marked .../Firaxis Games/Sid Meier's Civilization 4/Assets. From there just open the XML folder and look around. I decided to open up the Units folder and check out the Civ4UnitInfos.xml file. Each unit in the game has a listing just like this:

<UnitClassInfo>
<Type>UNITCLASS_HINDU_MISSIONARY</Type>
<Description>TXT_KEY_UNIT_HINDU_MISSIONARY</Description>
<iMaxGlobalInstances>-1</iMaxGlobalInstances>
<iMaxTeamInstances>-1</iMaxTeamInstances>
<iMaxPlayerInstances>3</iMaxPlayerInstances>
<DefaultUnit>UNIT_HINDU_MISSIONARY</DefaultUnit>
</UnitClassInfo>

The numbers in between reflect the total number of units of that type allowed in the entire map, for each team, and for each player. -1 means that there is no limit, and any number including 0 places a limit on that type. Try changing the number 3, starting the hindu religion in the game, and you'll see that you'll be able to build that many hindu missionaies. Anyway, I'm off to sleep now very exciting times ahead.

bhiita
Oct 27, 2005, 02:41 AM
:) I don't have the game yet, but try this program out... the best XML edotor I've come across... and it's free! XML Marker (http://symbolclick.com/)


http://symbolclick.com/index_files/intro.gif

the100thballoon
Oct 27, 2005, 04:57 AM
Notepad2 is also a great program for editing any type of code. Ive done basic work with XML and I know HTML so I'll probably just sit down and mess with it one day (prolly today or tomorow :lol: )

Flak
Oct 27, 2005, 05:25 AM
I'm going to be using Visual SlickEdit. It's nice because it has autoformatting if you setup an xml project. The same with Python. I've been messing around with and it saves a LOT of typing. Can't wait to get my hands (well, editor) on Civ IV, set up a project and just search through all of the code to see what's available.

Dom Pedro II
Oct 27, 2005, 03:25 PM
Ok, I'll try to help out a little before I go to sleep. First of all, everything we'll be modding will be in the folder marked .../Firaxis Games/Sid Meier's Civilization 4/Assets. From there just open the XML folder and look around. I decided to open up the Units folder and check out the Civ4UnitInfos.xml file. Each unit in the game has a listing just like this:

<UnitClassInfo>
<Type>UNITCLASS_HINDU_MISSIONARY</Type>
<Description>TXT_KEY_UNIT_HINDU_MISSIONARY</Description>
<iMaxGlobalInstances>-1</iMaxGlobalInstances>
<iMaxTeamInstances>-1</iMaxTeamInstances>
<iMaxPlayerInstances>3</iMaxPlayerInstances>
<DefaultUnit>UNIT_HINDU_MISSIONARY</DefaultUnit>
</UnitClassInfo>

The numbers in between reflect the total number of units of that type allowed in the entire map, for each team, and for each player. -1 means that there is no limit, and any number including 0 places a limit on that type. Try changing the number 3, starting the hindu religion in the game, and you'll see that you'll be able to build that many hindu missionaies. Anyway, I'm off to sleep now very exciting times ahead.


Does this determine the number of units that can be constructed at all? or the number of units that are allowed at any one time? So if you build the 3 Hindu Missionaries and then expend two of them, can you build two more?

If this is the case: I smell modified immortals :) and any other UU that is actually an elite unit that should be limited in the numbers that can be produced.

WildWeazel
Oct 27, 2005, 03:33 PM
I just looked in the xml folder and
:wow: those files are huge!

I guess I have my work cut out for me on that tutorial. :crazyeye:

Zurai
Oct 27, 2005, 09:07 PM
Yeah, I kinda wish they did one XML file per unit rather than one XML file with all 100+ units. It's a lot to slog through. Same with the buildings and a lot of the other "big systems".

They did an excellent job with their naming convention, though, with the only confusion I've had so far being with the Creative and Financial leader traits. The <CommerceChanges> and <ExtraYieldThreshold> tags really need to have descriptive sub-tags instead of repeating themselves (3 repetitions of <iCommerce> and <iExtraYieldThreshold>, respectively). Obviously they're affecting 3 different values (or, actually, since they're both set to 0 0 2, skipping two values and affecting the third...) but the XML doesn't tell you what values they are, and that leads to confusion. The 2's are culture and coins, but what are the 0's? No way to know without messing around with it.

WildWeazel
Oct 27, 2005, 09:10 PM
Yeah, I kinda wish they did one XML file per unit rather than one XML file with all 100+ units. It's a lot to slog through. Same with the buildings and a lot of the other "big systems".
Hopefullly somebody who is a better programmer than me will make an editor. Until then, I guess Ctrl-F works.

Chieftess
Oct 27, 2005, 09:13 PM
Hopefullly somebody who is a better programmer than me will make an editor. Until then, I guess Ctrl-F works.

You could do it with Python (cross-compatibility, but I think you'd need the python engine). I have .NET, but you need the .NET framework...

I still have Borland C++, but that's quirky. ;)

.NET can do XML though, I've tried it.

I actually find CTRL-F in notepad to work wonders. It's much easier to copy/paste in notepad than using a 3rd party XML tool. (they are out there...)

WildWeazel
Oct 27, 2005, 09:17 PM
Would it be possible in C? I have a final project coming up and I'm supposed to be deciding what my program is going to do. :mischief:

Zurai
Oct 27, 2005, 09:28 PM
Actually I may be able to whip up an XML viewer/editor, but it would be pretty ugly and would only be for specific files most likely. I'm familiar with parsing in XML data, the difficulty is purely in meshing it with an MFC framework (Microsoft Foundation Class - ie C++ equivalent of visual basic). Depending on how difficult it winds up being it may be a while before I get it done - I do have non-Civ tasks to do that take up a lot of my time ;)

Chieftess
Oct 27, 2005, 09:30 PM
You could make a parser even in C...

But, remember, there's so much to look at with the XML, and not one sample unit/building/etc. will do you justice. There could be nested XML code that one object doesn't have. It'll be a fun project if you like structs. (I just wished .NET didn't do away outright with arrays, structs and whatnot.... it's still there in, but in different forms.)

Zurai
Oct 27, 2005, 09:37 PM
The way I was thinking about doing it was pretty brute-force (at least for now). Manually compile a list of all the unit subtags, for example, then make a UnitXML struct and parse in all the units into a linked list or vector of the structs, then allow the user to edit all the fields.

Like I said, very brute force and hard coded and not exactly robust, but it'd be a start and would let you view and edit a single unit at a time.

The earliest I'd be able to even get started working on it is saturday afternoon, though.

Chieftess
Oct 27, 2005, 09:46 PM
I've dabbled in XML coding a little bit (so many nodes! :eek: ). I'm not too familar with it, but my strategy would be parsing it into a myriad of structures. The problem is making them dynamic... So, it would only be a limited use tool in that most of the stuff you add is rather static. (same as all other types of data)

popewiz
Oct 28, 2005, 12:01 AM
About my earlier post, the numbers tell you how many you can have at any 1 time. So your UU idea would definitely work out.

Isak
Oct 28, 2005, 02:22 AM
I've got the explanations for most of the XML tags (i'd say about 90%), and will be posting them as soon as I can get my hands on the 'full game' and get them verified.

Until then, if in doubt about any value, just ask :)

The <CommerceChanges> and <ExtraYieldThreshold> tags really need to have descriptive sub-tags instead of repeating themselves (3 repetitions of <iCommerce> and <iExtraYieldThreshold>, respectively). Obviously they're affecting 3 different values (or, actually, since they're both set to 0 0 2, skipping two values and affecting the third...) but the XML doesn't tell you what values they are, and that leads to confusion. The 2's are culture and coins, but what are the 0's? No way to know without messing around with it.

True, but that would make it impossible for us to mod in new Commerce types or Yield types, since we can't create new XML tags. :)

The easy way to find the meaning of the <iCommerce> and <iExtraYieldThresholds> is to open the GameInfo/CIV4CommerceInfos.xml and Terrain/CIV4YieldInfos.xml.

The CommerceInfos.xml file contains three entries: Gold, Research and Culture, and those correspond to the three values of <iCommerce>.

The YieldInfos.xml file also contains three entries: Food, Production and Commerce.


It'll take a while to learn how to navigate these files, but trust me, once you get a bit more familiar with them, everything is going to seem easy as a peach. :)

Zurai
Oct 28, 2005, 02:36 AM
The easy way to find the meaning of the <iCommerce> and <iExtraYieldThresholds> is to open the GameInfo/CIV4CommerceInfos.xml and Terrain/CIV4YieldInfos.xml.

The CommerceInfos.xml file contains three entries: Gold, Research and Culture, and those correspond to the three values of <iCommerce>.

The YieldInfos.xml file also contains three entries: Food, Production and Commerce.

Yep, I realized that after doing a bit more research :) Overall I'm very very impressed with just the XML - I havn't even touched the python yet except a brief glance at the map generation scripts.

Isak
Oct 28, 2005, 02:50 AM
Yep, I realized that after doing a bit more research :) Overall I'm very very impressed with just the XML - I havn't even touched the python yet except a brief glance at the map generation scripts.

Yeah, i'm pretty sure it will spell the end of our social lives for years to come :D

WildWeazel
Oct 28, 2005, 09:55 AM
Social lives?

Oh yeah, that pre-Civ placeholder. :D

Stardog13
Oct 28, 2005, 12:54 PM
I'll see if I can throw together a simple xml editor in the next couple of days, the question is should I hardcode the interface or make it completely dynamic?

What I think would really be more helpfull though is an index of all the xml data, there's just so much stuff there and it's hard to find what I want to; for now I've just been browsing through them.

Isak
Oct 28, 2005, 01:15 PM
What I think would really be more helpfull though is an index of all the xml data, there's just so much stuff there and it's hard to find what I want to; for now I've just been browsing through them.

It's a-comin'

I've got the explanations for most of the XML tags (i'd say about 90%), and will be posting them as soon as I can get my hands on the 'full game' and get them verified.

:)

weakciv
Oct 28, 2005, 01:18 PM
A good place to start if you still need a little help with XML is www.w3schools.com

rkyte
Oct 28, 2005, 04:06 PM
Yeah, I kinda wish they did one XML file per unit rather than one XML file with all 100+ units. It's a lot to slog through. Same with the buildings and a lot of the other "big systems".
You actually can do this pretty easily. One of the great things about xml is that it is easily manipulated with xsl. You can put every unit/building/tech in to its own file and then use xsl to combine them at the end. If you're clever you can have a big library of stuff and then just pick and choose which ones you want to put in the mod using xsl to do it.

<-- has been doing a lot of work lately with the Apache library.

Zurai
Oct 28, 2005, 10:17 PM
Holy hell I just looked more in depth at the unitinfos XML file... yeah, I'm definitely going to be making that unit xml editor because it's the only way I'll be able to keep all these things straight in my head :crazyeye:

Upside: expect a CIV4UnitInfos.xml editor hopefully by monday evening :D

Stardog13
Oct 28, 2005, 11:29 PM
Or we could just write some xsl files to display all those xmls in nice html tables :)

WildWeazel
Oct 28, 2005, 11:31 PM
Somebody enlighten me... what's xsl?

Stardog13
Oct 28, 2005, 11:36 PM
http://www.w3.org/Style/XSL/

Basically it allows you to change the way xml data is displayed.
Here's some short tutorials on it, you can just look through them to see what they can do; I'll try and write a quick on here and upload it.

http://www.w3schools.com/xsl/xsl_templates.asp

Edit:

Ok, here's a quick example; I'm sure there's a better way to do this then by actually changing civ's files but for now this is a good example. If you do try this please work on a copy of the files and not the ones in your civ folder.

-copy Assets\XML\Terrain\CIV4BonusInfos.xml to a different directory
-change the 8th line from <Civ4BonusInfos xmlns="x-schema:CIV4TerrainSchema.xml">
to <Civ4BonusInfos> (not sure why the schema is messing it up, haven't used any schemas before with xsl)
-add the following line just before the previous line <?xml-stylesheet type="text/xsl" href="BonusInfo.xsl"?>
-download the following file to the same directory as the copy you made and double click on the xml file (not the xsl).

Stardog13
Oct 29, 2005, 12:06 AM
Change the extension to .xsl and see above post.

Note that this is a very limited sample as to what you can do with xsl and as I said I'm sure there's a way to do this without directly modifying civ's files; just not sure of how right now.

WildWeazel
Oct 29, 2005, 04:44 PM
That looks much better. :cool:

Tunch Khan
Oct 29, 2005, 04:56 PM
You found a way to add a new civilization without overwriting the old ones?

tmservo
Oct 29, 2005, 05:19 PM
I'm still going through with a parser all of the XML files. Because they are intertwined, I'm looking for all the links to say, units, so that you can determine not only "how many" units, etc. but also the relative power (attack/defense) of a unit, links to the graphics, etc.

Very good stuff :)

tmservo
Oct 29, 2005, 08:02 PM
he best XML edotor I've come across... and it's free! XML Marker

Freaking GENIOUS. :) Speeding up my work right and left. Thanks to others here, I should have my first major sets of mods out quick :)

oldStatesman
Oct 29, 2005, 10:00 PM
Altova also has a free XML Editing Tool. It is the home version of XMLSpy - (I believe the professional version is the tool that Firaxis used for Civ4).

It is way too complex for me - it says it can convert XLM files to XLS files. The Text editor is what I got it for - it is much better that WordPad as there are color schemes. It will also Validate the XML file. You can also view the XML file as an html file.

Anyway, here is the link to the Free Home XMLSpy page. (They do ask for personal info in order to download it - but the app is fully functional and free.) ( I am not associated in any way with ths company.)

http://www.altova.com/download_components.html

WildWeazel
Oct 30, 2005, 07:39 PM
Isak, any idea when you will get Civ4 and how long it will take you to finish? I know it takes a while to get it in Europe.

Isak
Oct 30, 2005, 11:50 PM
Isak, any idea when you will get Civ4 and how long it will take you to finish? I know it takes a while to get it in Europe.

I should have it friday, and then it will take me approx. a week to put up short descriptions of each XML file and element. Then I'll make it public and start working on the detailed descriptions of each XML element (as necessary).

the100thballoon
Oct 31, 2005, 09:00 PM
I should have it friday, and then it will take me approx. a week to put up short descriptions of each XML file and element. Then I'll make it public and start working on the detailed descriptions of each XML element (as necessary).
You are wonderful.

WildWeazel
Oct 31, 2005, 09:16 PM
Yes, I forgot to mention that. Along with Trip, Isak is now on my favoritest people list. :D

rkyte
Nov 01, 2005, 12:48 PM
This sounds like a perfect project to set up a wiki for. For anyone unfamiliar with what a wiki is, check out wikipedia.org. That would provide an east, public interface for all of the information that can be updated any time something new is discovered.

BrentRitchie
Nov 01, 2005, 01:17 PM
I second the wiki idea. A centeral repository to wotk from would be so much easier to help figure out what each tag does. That way we don't spend time on tryiing to figure out tags that have already been confirmed. Also new modders will be able to make sense of the mass amount of files fairly quickly.

kattana
Nov 03, 2005, 08:04 AM
so...is that week up yet??

hehehe

Isak
Nov 03, 2005, 11:37 AM
Hardly, it's not even friday yet :D

The game is released tomorrow here in Denmark, but I'll be putting some of the documentation up in a few days or so. Might as well just make the files available as I go along.

.. oh, and some of the people in this thread must be psychic ... :scan:

WildWeazel
Nov 03, 2005, 11:48 AM
.. oh, and some of the people in this thread must be psychic ... :scan:
I smell wiki :mischief:

grallon
Nov 03, 2005, 11:58 AM
The only question I have is why wasn't there an interface, built into the main game engine, and designed to handle all of this ? Oh yes - it's probably done already but Firaxis will try to bill us another 50$ for it in a few months :rolleyes:


G.

Isak
Nov 03, 2005, 12:00 PM
The only question I have is why wasn't there an interface, built into the main game engine, and designed to handle all of this ? Oh yes - it's probably done already but Firaxis will try to bill us another 50$ for it in a few months :rolleyes:

Because the interface would only hamper us, like the Civ3 editor did.

Vino6
Nov 03, 2005, 12:02 PM
Hello, i was reading this thread and there was no way i couldn't post to it. I hope some of you who posted here could help me in my little project.
You can see what it is about in this thread:
http://forums.civfanatics.com/showthread.php?t=136733

It is mainly a Civ4 XML editor, i mean, the idea is to make an XML editor for everyone out there who doesn't know anything about xml, and for the ones out there who do know it, but, as i do, prefer to save their time for the playing itself.

WildWeazel
Nov 10, 2005, 11:33 PM
:bump:
Isak, any news? Did you get it yet?

deKoven
Nov 11, 2005, 07:05 AM
Altova also has a free XML Editing Tool. It is the home version of XMLSpy - (I believe the professional version is the tool that Firaxis used for Civ4).

It is way too complex for me - it says it can convert XLM files to XLS files. The Text editor is what I got it for - it is much better that WordPad as there are color schemes. It will also Validate the XML file. You can also view the XML file as an html file.

Anyway, here is the link to the Free Home XMLSpy page. (They do ask for personal info in order to download it - but the app is fully functional and free.) ( I am not associated in any way with ths company.)

http://www.altova.com/download_components.html
Yeppers, I went right to the site and picked it up yesterday. Looks freakin' good to me. I'm certainly not the sharpest knife in the drawer when it comes to any of the modern languages but it looks like even I can figger out small things. I'll be looking at XML Marker today to see if I like it better.

Kudos to all who make these free proggies for us $$-challenged players.

:D

rkyte
Nov 12, 2005, 07:50 PM
I smell wiki :mischief:
Isak, what the status in that wiki? (I suppose we're assuming at this point. You never outright said that was your plan.) I've got some spare bandwith and could get it up and running right now, although I doubt I'd want to host it indefinitely.

I've noticed some scattered discussion, but not much initiative in actually creating one. I think it would be a huge benefit to everyone. The sooner it is up and running the better.

Edit: Something else I've noticed. There have been a few threads started asking where to find information on xml tags. Someone always jumps in the thread and says "I'm working on it. Give me a few weeks." Invariably it's a different person each time. It seems like the process would go a lot faster if all of these people had an efficient way to collaborate. Right now they're mostly doing their own thing....

WildWeazel
Nov 12, 2005, 07:55 PM
The only downside to wiki is that anyone can post anything. Some people are bound to post information based on assumptions or guesses rather than tested information. Then everyone else reads it, assumes it's correct, and ends up with a bunch of bugs. I don't know much about wiki, but is there any way to "censor" what gets posted?

rkyte
Nov 12, 2005, 08:16 PM
The key to a good wiki is good administrators and a good userbase. Anyone can post anything. Anyone can add/delete/overwrite anything. But article histories are saved and if bad information is posted or someone improperly messes with an article it is easily corrected.

The userbase must reach a critical mass for it to be effective. With enough people participating, new information tends to get independently verified and bad/false information gets corrected. It has built in discussion pages and people can discuss questional additions without modifying the article.

Think about wikipedia. It's an exceptional site in spite of the fact that anyone can post anything. I rarely read anything there and say to myself "Can I trust this information? Some random schmuck wrote this!" As a whole, everything there is spot on. The same thing could apply here.

Mr. Will
Nov 12, 2005, 08:53 PM
I've already started a guide to just the LeaderHeadInfos.xml file (its in the tutorials/guides section), but most of it is blank or implied from the variable names. You're welcome to lend a hand in testing those variables or giving your input.

rkyte
Nov 12, 2005, 09:23 PM
Actually, your post is a great example of what a wiki is good for. Sure, anyone can contribute information to your thread, but only you can update the first post with up-to-date information. Also, cross-referencing your information with other threads is extremely difficult and only gets harder to keep up with as more threads are added to the forums.

Just for kicks I slapped a wiki up on my site and threw in an article for LeaderHeadInfos.xml

Main_Page (http://www.kyteland.com/wikitest/index.php/Main_Page)
Civ4LeaderHeadInfos (http://www.kyteland.com/wikitest/index.php/Civ4LeaderHeadInfos)

Mr. Will
Nov 12, 2005, 09:38 PM
We definitely need one of those.
It will make documenting the XML and eventually Python much easier.

A Civ4 Modder's Wiki. :goodjob:

The Great Apple
Nov 13, 2005, 07:22 AM
I'd love a wiki - and I think it would work. If it were to be opened now, for example, I would imagine we would already have a pretty comprehensive description of most of the tags between us.

Isak
Nov 13, 2005, 12:16 PM
Isak, what the status in that wiki? (I suppose we're assuming at this point. You never outright said that was your plan.) I've got some spare bandwith and could get it up and running right now, although I doubt I'd want to host it indefinitely.
Sorry - i'm still typing, but wouldn't mind making what's I have available to everybody. I just don't have any control over when it will be posted, but I'm tugging and pulling all that I can. Please stay tuned...