Page 1 of 1

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

PostPosted: Fri Sep 30, 2011 6:58 am
by Apo
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" />

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

PostPosted: Fri Sep 30, 2011 7:42 am
by Graveen
I see. The actual code is handling element similar as properties ?

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

PostPosted: Fri Sep 30, 2011 9:27 am
by Apo
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.).

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

PostPosted: Sun Oct 02, 2011 7:03 am
by Apo
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.

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

PostPosted: Sun Oct 02, 2011 6:40 pm
by Graveen
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 ?

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

PostPosted: Mon Oct 03, 2011 9:59 am
by Apo
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.