2 * Copyright (C) 2006, 2007 OpenedHand Ltd.
3 * Copyright (C) 2009 Nokia Corporation.
5 * Author: Jorn Baayen <jorn@openedhand.com>
6 * Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
7 * <zeeshan.ali@nokia.com>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
26 * SECTION:gupnp-xml-doc
27 * @short_description: GObject wrapper for xmlDoc.
29 * GObject wrapper for xmlDoc, so that we can use refcounting and weak
34 #include "gupnp-xml-doc.h"
35 #include "gupnp-error.h"
37 G_DEFINE_TYPE (GUPnPXMLDoc,
42 gupnp_xml_doc_init (G_GNUC_UNUSED GUPnPXMLDoc *doc)
48 gupnp_xml_doc_finalize (GObject *object)
52 doc = GUPNP_XML_DOC (object);
54 xmlFreeDoc (doc->doc);
56 G_OBJECT_CLASS (gupnp_xml_doc_parent_class)->finalize (object);
60 gupnp_xml_doc_class_init (GUPnPXMLDocClass *klass)
62 GObjectClass *object_class;
64 object_class = G_OBJECT_CLASS (klass);
66 object_class->finalize = gupnp_xml_doc_finalize;
71 * @xml_doc: Pointer to #xmlDoc to wrap under this object
73 * Create a new #GUPnPXMLDoc for @xml_doc.
75 * Return value: A new #GUPnPXMLDoc, or %NULL on an error
78 gupnp_xml_doc_new (xmlDoc *xml_doc)
82 g_return_val_if_fail (xml_doc != NULL, NULL);
84 doc = g_object_new (GUPNP_TYPE_XML_DOC, NULL);
92 * gupnp_xml_doc_new_from_path:
93 * @path: Path to xml document
94 * @error: Location to put the error into
96 * Create a new #GUPnPXMLDoc for the XML document at @path.
98 * Return value: A new #GUPnPXMLDoc, or %NULL on an error
101 gupnp_xml_doc_new_from_path (const char *path,
107 flags = XML_PARSE_PEDANTIC;
109 if (!g_getenv ("GUPNP_DEBUG")) {
110 flags |= XML_PARSE_NOWARNING | XML_PARSE_NOERROR;
113 g_return_val_if_fail (path != NULL, NULL);
114 doc = xmlReadFile (path, NULL, flags);
118 GUPNP_XML_ERROR_PARSE,
119 "Failed to parse %s\n",
125 return gupnp_xml_doc_new (doc);