SFML community forums
General => Feature requests => Topic started by: slotdev on January 20, 2012, 02:29:11 pm
-
An XML parser? I know there are many out there (too many, if you ask me) but so many have bugs, memory leaks and are just not as user-friendly as sf::XML would surely be :-)
-
I'm glad you think that I can write a better XML library than everything else that already exists, but seriously... no ;)
There are many good XML libraries, I'm surprised that you can't find one that's perfect for you.
-
Try pugixml (http://pugixml.org/). It's very small, has a low memory footprint (almost none, as you can force it to work with your input buffer), easy to use and you don't have to handle empty keys or not existing elements (e.g. you can query the value of attribute x of element y even though element y doesn't even exist, which will return 0 or "").
-
sounds nice, using tinyxml but error handling doesnt exist..a single xml file error and it crashes everything...
I might have to take a looK! Thank you for suggestion..anymore?
using it for loading Tild maps and animation files
-
I load Tiled maps with TinyXML :)
-
I was planning on recommending pugixml if it hadn't been brought up yet. I prefer using JSON wherever possible, but pugixml is my library of choice when I use XML.
-
I prefer to use YAML, mostly because it comes built in to ruby.
-
What is the best for C++? :D
-
What is the best for C++? :D
As already said above: tinyxml and pugixml both work really well for C++ and are easy to integrate in a project, but pugixml is a bit more forgiving conerning malformed xml syntax.
-
What is the best for C++?
There's no best, it depends on your requirements. The best for you might not be the best for me.
XML libraries are designed for different things: some have the smallest possible memory consumption, some provide the fastest parser, some provide a clean C++ API, some provide support for DTD, DOM, XPath, XSLT, SAX, ... The XML world is wide.
-
Or libxml2, it's a C library but it's used and maintained by gnome-project, so it's quite good, and supports lots of things.
-
If you are willing you could look at other options than just XML. One of them might just take your fancy. I can't say how it is for C++ but it should be similar but when using YAML it's more or less:
# Yaml file
- 5
- 10
- "Hello World!"
# Source file
array = YAML.load_file( "file.yaml" )
array[ 0 ] == 5
array[ 1 ] == 10
array[ 2 ] == "Hello World!"
NOTE: Found an C++ implementation and here's the getting started tutorial: http://code.google.com/p/yaml-cpp/wiki/Tutorial
-
boost::property_tree has an XML reader/writer, among others.
-
NOTE: Found an C++ implementation and here's the getting started tutorial: http://code.google.com/p/yaml-cpp/wiki/Tutorial
Looks quite interesting, thanks!
-
boost::property_tree has an XML reader/writer, among others
It uses the rapidxml library.
-
I currently use irrXML which is full of bugs and very slow, due to it doing a malloc for pretty much everything. Very annoying.
But I'll take a look at pugixml and the others, thanks :)