Skip to main content
gamedev.net
🔒 Locked

which xml parser?

Started by kzar 8 replies 950+ views
Original Post
kzar
kzar
Hey i have been searching around the forums about which xml parser to use. Tinyxml sounds pretty good but its c++ and my project is c so that wont work? I would prefer if it didnt need a extra dll but i suppose it woudlnt matter tooo much. Any sugestions?
Koshmaar
Koshmaar
1. You can't use C++ project in C (but the other way around is legal). My best advice here is that you should learn C++ (if you already know C it won't be that hard)
2. TinyXML can be static library (you have to compile it yourself, so you are free to make any choice)
3. Search at Sourceforge for sth like "XML parser C" - should help

Cheers
kzar
kzar
so i could compile it to a dll and then just have that in the directory?
evolutional
evolutional
What about libXml, that's written in C and has wrappers for many other languages.
kzar
kzar
libxml looks good, problem is its a bit confusing. On the examples page (here) there are loads of different examples of all kinds of things. Im a bit confused at which is what i would want to do in my program. I want to load a file with all the information about a level into a few different structure arrays. I dont see the difference between "Parse an XML file to a tree and free it" and "Parse an XML file with an xmlReader". Sorry if im being stupid.
Xai
Xai
parse into a tree reads the WHOLE thing into the tree ... then you use tree ops to walk and browse the tree data as needed ...

parse using a reader is like reading from a stream ... you pull nodes (or possibly it pushes nodes) - as it encounters them ...

so while using the reader version ... the library doesn't keep things like



in memory while your down at the bottom of the file reading:


...

but the tree versions let you do cool stuff like use XPath that you cannot do using the reader system ...

in other words, think of the reader as being like iostreams ... and the tree version as being like having it stored in memory in a random access collection.
leiavoia
leiavoia
TinyXML compiles directly into your project. That's why it's so cool. It's not a library proper. (although i'm sure you could create it that way).
kzar
kzar
how would i compiles tinyxml to be astatic library in somthing like dev-c++ ? would i just add the files to my project?
leiavoia
leiavoia
It only has like a half dozen files to it. You just throw them in with the rest of your project's files and use it just as if you wrote the code yourself!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.