Changed regions.xml and zones.xml, xml node structure

Share files with other Dawn of Light users

Moderator: Support Team

Changed regions.xml and zones.xml, xml node structure

Postby Apo » Fri Sep 30, 2011 6:58 am

I use this for "private" coding.

Before: default xml node structure (<node><id></id><description></description></node>)
Now: one xml node with attributes (<node id ="" description ="" />)
Code: Select all
<region id="1" description="Albion" expansion="0" isDivingEnabled="1" isHousingEnabled="0" waterLevel="0" ip="127.0.0.1" port="10400" />
Code: Select all
<zone id="0" description="Camelot Hills" regionId="1" isLava="0" height="8" width="8" xOffset="67" yOffset="59" />
Attachments
config.rar
(6.91 KiB) Downloaded 263 times
Apo
Contributor
 
Posts: 341
Joined: Sun May 22, 2005 10:21 pm
Location: Germany

Re: Changed regions.xml and zones.xml, xml node structure

Postby Graveen » Fri Sep 30, 2011 7:42 am

I see. The actual code is handling element similar as properties ?
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: Changed regions.xml and zones.xml, xml node structure

Postby Apo » Fri Sep 30, 2011 9:27 am

In this way. You must call a node-attribute(name)-value property -> XElement.Attribute(attributeName).Value.

As example:
Code: Select all
int val = -1;
XDocument doc = XDocument.Load(filePath);

foreach(XElement element in doc.Root.Nodes)
{
if(element.Attribute(attributeName) != null)
val = Convert.ToInt32(element.Attribute(attributeName).Value);
}
It's also possible to use linq querys (select node where id ... etc.).
Apo
Contributor
 
Posts: 341
Joined: Sun May 22, 2005 10:21 pm
Location: Germany

Re: Changed regions.xml and zones.xml, xml node structure

Postby Apo » Sun Oct 02, 2011 7:03 am

And here is the source code of the app. I've writen to convert the default files.

Please note that this app is writen in a way where YOU KNOW_what_ you're doing with it - this means, that there is not many exception handling.
Attachments
dolConverter.rar
(5.69 KiB) Downloaded 56 times
Apo
Contributor
 
Posts: 341
Joined: Sun May 22, 2005 10:21 pm
Location: Germany

Re: Changed regions.xml and zones.xml, xml node structure

Postby Graveen » Sun Oct 02, 2011 6:40 pm

Thank you. I don't precisely see if it is really better (in term of readability when parsing XML in example). If it have real benefits, i guess i'll think about let you include in the core :)

but quickly, i'm not sure i see precisely why it is better, can you tell me what leaded you to write such a converter ?
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: Changed regions.xml and zones.xml, xml node structure

Postby Apo » Mon Oct 03, 2011 9:59 am

Thats correct, it isn't really better than the actual XMLConfigFile, it's just for a better readability - the XMLConfigFile is more user friendly.

But it's also easier to include regions and zones in external projects without a dol framework reference or a copy of the XMLConfigFile and ConfigElement classes - all I have to do is creating a new XDocument instance.
but quickly, i'm not sure i see precisely why it is better, can you tell me what leaded you to write such a converter ?
Well, I have my "own" rewrite of DOL - adapted for personal use.
Apo
Contributor
 
Posts: 341
Joined: Sun May 22, 2005 10:21 pm
Location: Germany


Return to “%s” User Files

Who is online

Users browsing this forum: No registered users and 1 guest