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
36 #include "gupnp-xml-doc.h"
37 #include "gupnp-error.h"
39 G_DEFINE_TYPE (GUPnPXMLDoc,
44 gupnp_xml_doc_init (G_GNUC_UNUSED GUPnPXMLDoc *doc)
50 gupnp_xml_doc_finalize (GObject *object)
54 doc = GUPNP_XML_DOC (object);
56 xmlFreeDoc (doc->doc);
58 G_OBJECT_CLASS (gupnp_xml_doc_parent_class)->finalize (object);
62 gupnp_xml_doc_class_init (GUPnPXMLDocClass *klass)
64 GObjectClass *object_class;
66 object_class = G_OBJECT_CLASS (klass);
68 object_class->finalize = gupnp_xml_doc_finalize;
73 * @xml_doc: Pointer to #xmlDoc to wrap under this object
75 * Create a new #GUPnPXMLDoc for @xml_doc.
77 * Return value: A new #GUPnPXMLDoc, or %NULL on an error
82 gupnp_xml_doc_new (xmlDoc *xml_doc)
86 g_return_val_if_fail (xml_doc != NULL, NULL);
88 doc = g_object_new (GUPNP_TYPE_XML_DOC, NULL);
96 * gupnp_xml_doc_new_from_path:
97 * @path: Path to xml document
98 * @error: Location to put the error into
100 * Create a new #GUPnPXMLDoc for the XML document at @path.
102 * Return value: A new #GUPnPXMLDoc, or %NULL on an error
107 gupnp_xml_doc_new_from_path (const char *path,
113 flags = XML_PARSE_PEDANTIC;
115 if (!g_getenv ("GUPNP_DEBUG")) {
116 flags |= XML_PARSE_NOWARNING | XML_PARSE_NOERROR;
119 g_return_val_if_fail (path != NULL, NULL);
120 doc = xmlReadFile (path, NULL, flags);
124 GUPNP_XML_ERROR_PARSE,
125 "Failed to parse %s\n",
131 return gupnp_xml_doc_new (doc);