Working with XML, anyone knows a nice guide?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, XML as an internal data representation sucks IMHO, so that's not really a problem. And yeah, DOM is not implemented, as I said. But on the important read/write level it's pretty much the same effort for both tools.
Most editors can use the 32bit wchar_t files... I'm using vim, but Linux has pretty good support for any kind of encoding.
CuteAlien
Admin
Posts: 9933
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I tried vim and all I got was texts "l i k e t h a t". I also tried nano, kate, c::b and I even downloaded some more editors just to try it and so far none(!) could do it. I have no idea how you manage to do that with vim, but I'm no regular vim user anyway. On windows I can use notepad++ which has no problems at all. The only solution on Linux which partly worked was converting the files before editing them using other tools. But I'm no bash-guru and so I failed converting them all at once and I have to work with around 50 files which are saved again each time I write them with irrXML, so I gave up by now and reboot each time.

Reading & writing is a somewhat similar complexity if you put together data-access and file-access for tinyXml. Well, tinyXml is maybe a little simpler as you don't care about doing part of the parsing yourself and writing stuff like closing-tags. You simply don't work on that level. It is more comparable to IAttributes - except that IAttributs is flat and not treelike.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Hmm, don't know why it doesn't work. Maybe lack of encoding support on your system.
TinyXML seems to require the LinkEndChild calls, which is pretty much the same, isn't it? And of course you don't do the parsing, you navigate through the tree. But as long as you don't navigate back it's pretty much the same. Just use a SAX parser next time and you'll have the same things as irrXML does. So I don't think that irrXML is really useful for anything else than serialization stuff, but I also think that it was not intended for anything else.
CuteAlien
Admin
Posts: 9933
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Lacking encoding support of the system itself? Maybe you're right, it's not an idea which crossed my mind so far. Do you have an idea how that can be added (yeah, I google it later on, but maybe you know it already...).

LinkEndChild is not to announce the end of an element, but it's about adding an element in a certain place in the tree (here at the end of a parent, but other places are also possible). So it's more like writeElement while the closing is done automatically. But it's really hard to compare those libs as they approach xml on completely different levels. Like I wrote it's much more like IAttributes, but IAttributes is flat which leads for example to some strange constructs in serialization like all those loops where all subelements have to use labels which contain the counter.

Also I do usually work rather different with tinyXml than Acki when I'm using tinyXml. I do mostly see the application as the one which has to work with existing xml's instead of defining them, so my applications will not do structural changes to the xml. I usually look for elements and when they are available I change them (and in some cases I might also create them if they are not available). Unknown elements will not be changed. This way I have for example no problems if someone adds comments to the xml's - they will just stay in. And I guess it's not hard to see that for this task tinyXml is more suited.

But please don't get me wrong. I also use irrXML *a lot* and I doubt that many people here use the serialization features as much as I do ;-). Which probably is the reason why the 32-bit wchar_t trouble does hurt and bother me so much. I really, really hope I find some day the time to change the code so it allows setting the encoding for irrXML on writing which would solve that problem in a clean way and would be great anyway. Unfortunately it's not so trivial doing that in a clean way. I could cheat like it's done on reading right now and do a 1:1 copy of each char element, but that's not correct as unicode codepositions can be defined by several chars. And unfortunately I need real unicode sometimes.

And sorry for bringing this stuff up in here. It's really the wrong thread for that.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

of course with tinyXML you also can change already existing attributes...

Code: Select all

elm->SetAttribute(...)
in my example I just created a new XML file... ;)

and another thing is that if you want to use XML in other apps than Irrlicht, you'll have to use another XML lib (like tinyXML) so why should I use 2 different libs that are doing the same thing and learn both of them as far as they don't have the same syntax ?!?!? :shock:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
CuteAlien
Admin
Posts: 9933
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Acki wrote:and another thing is that if you want to use XML in other apps than Irrlicht, you'll have to use another XML lib (like tinyXML) so why should I use 2 different libs that are doing the same thing and learn both of them as far as they don't have the same syntax ?!?!? :shock:
Don't be so lazy :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

but lazyness makes life much easier !!! :lol:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

irrXML is also available separately :roll:
Morgawr
Posts: 95
Joined: Wed Sep 26, 2007 7:04 pm

Post by Morgawr »

hybrid wrote:irrXML is also available separately :roll:
by including irrXML.h instead of irrlicht.h right? :oops:
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, Niko has a separate irrXML package for download, but I guess it would be enough to put all *XML* files into your project and include irrXML.h, yes. I never needed SAX parsers outside Irrlicht code, so I never used it, yet.
Post Reply