6 * Copyright (C) 2010 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 typedef struct _sipe_xml sipe_xml
;
26 * Parse XML from a string.
28 * @param string String with the XML to be parsed.
29 * @param length Length of the string.
31 * @return Parsed XML information. Must be @c sipe_xml_free()'d.
33 sipe_xml
*sipe_xml_parse(const gchar
*string
, gsize length
);
36 * Free XML information.
38 * @param string XML information to be freed.
40 void sipe_xml_free(sipe_xml
*xml
);
43 * Convert XML information to string.
45 * @param xml XML information.
47 * @return XML converted to a string. Must be @c g_free()'d.
49 gchar
*sipe_xml_stringify(const sipe_xml
*xml
);
52 * Gets a child node named name.
54 * @param parent The parent node.
55 * @param name relative XPATH of the child (a, a/b, a/b/c, etc.).
57 * @return The child or @c NULL. Never try to @c sipe_xml_free() it!
59 const sipe_xml
*sipe_xml_child(const sipe_xml
*parent
, const gchar
*name
);
62 * Gets the next node with the same name as node.
64 * @param node The node of a twin to find.
66 * @return The twin of node or @c NULL.
68 const sipe_xml
*sipe_xml_twin(const sipe_xml
*node
);
71 * Gets the name from the current XML node.
73 * @param node The node to get the name from.
75 * @return The name of the node
77 const gchar
*sipe_xml_name(const sipe_xml
*node
);
80 * Gets an attribute from the current XML node.
82 * @param node The node to get an attribute from.
83 * @param attr The attribute to get.
85 * @return The value of the attribute or @c NULL.
87 const gchar
*sipe_xml_attribute(const sipe_xml
*node
, const gchar
*attr
);
90 * Gets an attribute from the current XML node and convert it to an
93 * @param node The node to get an attribute from.
94 * @param attr The attribute to get.
95 * @param fallback Default value if the attribute doesn't exist.
97 * @return Attribute value converted to an integer or the fallback value.
99 guint
sipe_xml_int_attribute(const sipe_xml
*node
, const gchar
*attr
,
103 * Gets escaped data from the curretn XML node.
105 * @param node The node to get data from.
107 * @return The data from the node or @c NULL. Must be @c g_free()'d.
109 gchar
*sipe_xml_data(const sipe_xml
*node
);