Before an XML file can be loaded, you must create a GstXML object. A saved XML file can then be loaded with the gst_xml_parse_file (xml, filename, rootelement) method. The root element can optionally left NULL. The following code example loads the previously created XML file and runs it.
#include <stdlib.h> #include <gst/gst.h> int main(int argc, char *argv[]) { GstXML *xml; GstElement *pipeline; gboolean ret; gst_init (&argc, &argv); xml = gst_xml_new (); ret = gst_xml_parse_file(xml, "xmlTest.gst", NULL); g_assert (ret == TRUE); pipeline = gst_xml_get_element (xml, "pipeline"); g_assert (pipeline != NULL); gst_element_set_state (pipeline, GST_STATE_PLAYING); g_sleep (4); gst_element_set_state (pipeline, GST_STATE_NULL); exit (0); }
gst_xml_get_element (xml, "name") can be used to get a specific element from the XML file.
gst_xml_get_topelements (xml) can be used to get a list of all toplevel elements in the XML file.
In addition to loading a file, you can also load from a xmlDocPtr and an in-memory buffer using gst_xml_parse_doc and gst_xml_parse_memory respectively. Both of these methods return a gboolean indicating success or failure of the requested action.