SFML community forums

General => Feature requests => Topic started by: slotdev on January 20, 2012, 02:29:11 pm

Title: sf::XML
Post 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 :-)
Title: sf::XML
Post by: Laurent on January 20, 2012, 02:34:26 pm
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.
Title: sf::XML
Post by: Mario on January 20, 2012, 04:19:10 pm
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 "").
Title: sf::XML
Post by: Elgan on January 20, 2012, 07:40:57 pm
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
Title: sf::XML
Post by: N1ghtly on January 22, 2012, 08:48:15 pm
I load Tiled maps with TinyXML :)
Title: sf::XML
Post by: TechRogue on January 23, 2012, 01:26:53 am
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.
Title: sf::XML
Post by: Groogy on January 23, 2012, 02:18:32 am
I prefer to use YAML, mostly because it comes built in to ruby.
Title: sf::XML
Post by: TheEnigmist on January 23, 2012, 01:03:29 pm
What is the best for C++? :D
Title: sf::XML
Post by: tobybear on January 23, 2012, 01:10:50 pm
Quote from: "TheEnigmist"
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.
Title: sf::XML
Post by: Laurent on January 23, 2012, 01:17:40 pm
Quote
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.
Title: sf::XML
Post by: danman on January 23, 2012, 10:13:38 pm
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.
Title: sf::XML
Post by: Groogy on January 23, 2012, 10:18:58 pm
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:

Code: [Select]
# 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
Title: sf::XML
Post by: raycrasher on January 30, 2012, 09:06:22 am
boost::property_tree has an XML reader/writer, among others.
Title: sf::XML
Post by: Nexus on January 30, 2012, 09:23:34 am
Quote from: "Groogy"
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!
Title: sf::XML
Post by: Laurent on January 30, 2012, 09:53:14 am
Quote
boost::property_tree has an XML reader/writer, among others

It uses the rapidxml library.
Title: sf::XML
Post by: slotdev on January 30, 2012, 01:13:52 pm
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 :)