GXml provides a GObject API for XML manipulation.


  • DOM Level 1 Core API[0]
  • select DOM Level 2 Core API support (for namespaces)
  • built atop libxml2 for proven performance
  • GObject serialization

Its development has been sponsored through

  • 2012 Google Summer of Code (Serialisation)
  • 2011 Google Summer of Code (DOM Level 1 Core API)

0. http://www.w3.org/TR/DOM-Level-1/idl-definitions.html


Progress can be tracked by blog posts at:



Updated: 2012-08-20

  • finished Serialization class (automatically handles most of GObjects)
  • finished Serializable interface (allows classes to handle parts of serialization themselves)
  • finished test cases. (Some target features for the future, e.g. finding a magical way to serialize private fields, and thus are supposed to fail at present, run the test suite with -k to not block on those)
  • finished documentation (GtkDoc style for devhelp!)

  • uses autotools (built on work from Daniel Espinoza)

source tree

It's living at GNOME's Git repositories:


release as of 2012-08-20:



Please file bugs at: https://bugzilla.gnome.org/browse.cgi?product=gxml

SAX notes

Simple API for XML.

libxml2 API:

Wikipedia description:

Java, the de facto standard:

Java provides users with a DefaultHandler to handle SAX parsing. Users can extend it and override methods to handle different events themselves. Such methods include

  • {start,end}{Document,Element}, characters, comment, etc.

Serialization notes

Serialization is being added as part of GSoC 2012 along with some other features: http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/aquarichy/17003


  • convert GObjects (and potentially) GVariants to XML
  • be able to serialise XML to disk and back
  • perhaps have a generic interface so we could have an XML or a JSON back end

Serialization as XML GObject Model

As for .NET implementation, actual work at serialization branch, adds to Serializable interface with methods to convert any GObject implementing it as a GObject representation of XML nodes.

XML GObject Model, allows to consider a GXml.Element as a GObject and GXml.Attr as properties, where any GObject property is handle as a child GXml.Element tag.

Serialization class will be used to actual implementation of serialization process.

A new GXml.ObjectModel abstract class has been added to easy Serializable classes implementation. As you can see at some Tests.

Comming features will include:

  • Handle GLib.Array<G>, GLib.HashTable<G>, arrays properties, by emitting events and providing default handlers

  • Emit events on unknown nodes or properties present in existing XML deserializable
  • Allows Unknown Elements and properties to be handle and saved without any change
  • Fix most GXml bugs in the process
  • Request for master merging

existing methods

.NET XML serialisation http://msdn.microsoft.com/en-us/library/ms950721.aspx

JSON serialisation http://live.gnome.org/JsonGlib


Buzztard (digital music studio)

with their BtPersistence

website: http://buzztard.org/

source: http://sourceforge.net/scm/?type=git&group_id=55124

BtPersistence's .c: http://buzztard.git.sourceforge.net/git/gitweb.cgi?p=buzztard/buzztard;a=blob;f=src/lib/core/persistence.c;h=3a969d56515046437f08644948021db6dc70f0c2;

BtPersistence's .h: http://buzztard.git.sourceforge.net/git/gitweb.cgi?p=buzztard/buzztard;a=blob;f=src/lib/core/persistence.h;h=5e9d08c91a062019df8917ab01dfa2af51b24af0;hb=HEADhb=HEAD

  • can save GLists, GHashTables
  • heart: bt_persistence_{save,load}
  • works with libxml
  • functions to convert GValues to strings and vice versa
  • serialisable objects implement BtPersistence interface, and the save() and load() methods

    • save() takes a serialisable object, returns an xmlNodePtr
    • load() takes an xmlNodePtr and either fills a serialisable object or instantiates a new one from a type


source: http://git.gnome.org/browse/goffice/

go-data.c at http://git.gnome.org/browse/goffice/tree/goffice/data/go-data.c

  • has go_data_serialize and go_data_unserialize
  • not sure if this is the serialisation that Stefan Sauer mentioned, need to investigate further

related projects


We hope to incorporate this as an element tree component to GXml.

http://git.gnome.org/browse/libgeexml/ A library implementing an API inspired by python etree.

https://gitorious.org/libgeexml-gdom A testing branch, trying to bring the above up to date and relearning some vala.


Short term plans include (summer 2012)

  • XML reader/writer stream
  • SAX parsing
  • performance measurements to make sure we're not catastrophically slower or heavier than libxml2
  • object serialisation
    • GVariant too, potentially
  • ElementTree based on libgeexml (perhaps)

Long term ideas include:

  • DOM Level 3 Core support (delicious namespacery!)
  • XPath support
  • XQuery support
  • native implementation (rather than just wrapping libxml2)

Outreach/SummerOfCode/2012/Projects/RichardSchwarting_GXml (last edited 2013-12-03 18:33:51 by WilliamJonMcCann)