[librest/xml: 2/4] Add rest_xml_parser_parse_from_data_full
- From: Ross Burton <rburton src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librest/xml: 2/4] Add rest_xml_parser_parse_from_data_full
- Date: Tue, 5 Oct 2010 12:05:49 +0000 (UTC)
commit 96e60c57663e949c34a248ac62ffa86da1c636aa
Author: Ross Burton <ross linux intel com>
Date: Thu Aug 12 14:56:34 2010 +0100
Add rest_xml_parser_parse_from_data_full
This allows the caller to pass in a base URI and character encoding.
rest/rest-xml-parser.c | 27 +++++++++++++++++++++++++--
rest/rest-xml-parser.h | 6 ++++++
2 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/rest/rest-xml-parser.c b/rest/rest-xml-parser.c
index 0d78273..bfffa79 100644
--- a/rest/rest-xml-parser.c
+++ b/rest/rest-xml-parser.c
@@ -277,6 +277,29 @@ rest_xml_parser_parse_from_data (RestXmlParser *parser,
const gchar *data,
goffset len)
{
+ return rest_xml_parser_parse_from_data_full (parser, data, len, NULL, NULL);
+}
+
+/**
+ * rest_xml_parser_parse_from_data_full:
+ * @parser: a #RestXmlParser
+ * @data: the XML content to parse
+ * @len: the length of @data
+ * @base_url: the base URL, or %NULL if unknown
+ * @encoding: the character encoding, or %NULL if unknown
+ *
+ * Parse the XML in @data, and return a new #RestXmlNode. If @data is invalid
+ * XML, %NULL is returned.
+ *
+ * Returns: a new #RestXmlNode, or %NULL if the XML was invalid.
+ */
+RestXmlNode *
+rest_xml_parser_parse_from_data_full (RestXmlParser *parser,
+ const gchar *data,
+ goffset len,
+ const gchar *base_url,
+ const gchar *encoding)
+{
xmlTextReaderPtr reader;
RestXmlNode *cur_node = NULL;
RestXmlNode *new_node = NULL;
@@ -295,8 +318,8 @@ rest_xml_parser_parse_from_data (RestXmlParser *parser,
reader = xmlReaderForMemory (data,
len,
- NULL, /* URL? */
- NULL, /* encoding */
+ base_url,
+ encoding,
XML_PARSE_RECOVER | XML_PARSE_NOCDATA);
while (xmlTextReaderRead (reader) == 1)
diff --git a/rest/rest-xml-parser.h b/rest/rest-xml-parser.h
index 967c2cf..54ea449 100644
--- a/rest/rest-xml-parser.h
+++ b/rest/rest-xml-parser.h
@@ -83,6 +83,12 @@ RestXmlNode *rest_xml_parser_parse_from_data (RestXmlParser *parser,
const gchar *data,
goffset len);
+RestXmlNode *rest_xml_parser_parse_from_data_full (RestXmlParser *parser,
+ const gchar *data,
+ goffset len,
+ const gchar *base_url,
+ const gchar *encoding);
+
GType rest_xml_node_get_type (void);
RestXmlNode * rest_xml_node_ref (RestXmlNode *node);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]