1 <!-- ##### SECTION Title ##### -->
2 Simple XML Subset Parser
4 <!-- ##### SECTION Short_Description ##### -->
7 <!-- ##### SECTION Long_Description ##### -->
9 The "GMarkup" parser is intended to parse a simple markup format
10 that's a subset of XML. This is a small, efficient, easy-to-use
11 parser. It should not be used if you expect to interoperate with other
12 applications generating full-scale XML. However, it's very useful for
13 application data files, config files, etc. where you know your
14 application will be the only one writing the file. Full-scale XML
15 parsers should be able to parse the subset used by GMarkup, so you can
16 easily migrate to full-scale XML at a later time if the need arises.
20 GMarkup is not guaranteed to signal an error on all invalid XML; the
21 parser may accept documents that an XML parser would not. However, XML
22 documents which are not well-formed<footnote id="wellformed">Being wellformed
23 is a weaker condition than being valid. See the
24 <ulink url="http://www.w3.org/TR/REC-xml/">XML specification</ulink> for
25 definitions of these terms.</footnote> are not considered valid GMarkup
30 Simplifications to XML include:
34 Only UTF-8 encoding is allowed.
39 No user-defined entities.
44 Processing instructions, comments and the doctype declaration are "passed
45 through" but are not interpreted in any way.
57 The markup format does support:
71 5 standard entities: <literal>&amp; &lt; &gt; &quot; &apos;</literal>
81 Sections marked as CDATA
87 <!-- ##### SECTION See_Also ##### -->
92 <!-- ##### SECTION Stability_Level ##### -->
95 <!-- ##### ENUM GMarkupError ##### -->
97 Error codes returned by markup parsing.
100 @G_MARKUP_ERROR_BAD_UTF8: text being parsed was not valid UTF-8
101 @G_MARKUP_ERROR_EMPTY: document contained nothing, or only whitespace
102 @G_MARKUP_ERROR_PARSE: document was ill-formed
103 @G_MARKUP_ERROR_UNKNOWN_ELEMENT: error should be set by #GMarkupParser functions; element wasn't known
104 @G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE: error should be set by #GMarkupParser functions; attribute wasn't known
105 @G_MARKUP_ERROR_INVALID_CONTENT: error should be set by #GMarkupParser functions; content was invalid
106 @G_MARKUP_ERROR_MISSING_ATTRIBUTE: error should be set by #GMarkupParser functions; a required attribute was missing
108 <!-- ##### MACRO G_MARKUP_ERROR ##### -->
110 Error domain for markup parsing. Errors in this domain will
111 be from the #GMarkupError enumeration. See #GError for information on
117 <!-- ##### ENUM GMarkupParseFlags ##### -->
119 Flags that affect the behaviour of the parser.
122 @G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG: flag you should not use.
123 @G_MARKUP_TREAT_CDATA_AS_TEXT: When this flag is set, CDATA marked
124 sections are not passed literally to the @passthrough function of
125 the parser. Instead, the content of the section (without the
126 <literal><![CDATA[</literal> and <literal>]]></literal>) is
127 passed to the @text function. This flag was added in GLib 2.12.
128 @G_MARKUP_PREFIX_ERROR_POSITION: Normally errors caught by GMarkup
129 itself have line/column information prefixed to them to let the
130 caller know the location of the error. When this flag is set the
131 location information is also prefixed to errors generated by the
132 #GMarkupParser implementation functions.
134 <!-- ##### STRUCT GMarkupParseContext ##### -->
136 A parse context is used to parse a stream of bytes that you expect to
137 contain marked-up text. See g_markup_parse_context_new(),
138 #GMarkupParser, and so on for more details.
142 <!-- ##### STRUCT GMarkupParser ##### -->
144 Any of the fields in #GMarkupParser can be %NULL, in which case they
145 will be ignored. Except for the @error function, any of these
146 callbacks can set an error; in particular the
147 %G_MARKUP_ERROR_UNKNOWN_ELEMENT, %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
148 and %G_MARKUP_ERROR_INVALID_CONTENT errors are intended to be set
149 from these callbacks. If you set an error from a callback,
150 g_markup_parse_context_parse() will report that error back to its caller.
153 @start_element: Callback to invoke when the opening tag of an element
155 @end_element: Callback to invoke when the closing tag of an element is seen.
156 Note that this is also called for empty tags like
157 <literal><empty/></literal>.
158 @text: Callback to invoke when some text is seen (text is always
159 inside an element). Note that the text of an element may be spread
160 over multiple calls of this function. If the %G_MARKUP_TREAT_CDATA_AS_TEXT
161 flag is set, this function is also called for the content of CDATA marked
163 @passthrough: Callback to invoke for comments, processing instructions
164 and doctype declarations; if you're re-writing the parsed document,
165 write the passthrough text back out in the same position. If the
166 %G_MARKUP_TREAT_CDATA_AS_TEXT flag is not set, this function is also
167 called for CDATA marked sections.
168 @error: Callback to invoke when an error occurs.
170 <!-- ##### FUNCTION g_markup_escape_text ##### -->
180 <!-- ##### FUNCTION g_markup_printf_escaped ##### -->
190 <!-- ##### FUNCTION g_markup_vprintf_escaped ##### -->
200 <!-- ##### FUNCTION g_markup_parse_context_end_parse ##### -->
210 <!-- ##### FUNCTION g_markup_parse_context_free ##### -->
218 <!-- ##### FUNCTION g_markup_parse_context_get_position ##### -->
228 <!-- ##### FUNCTION g_markup_parse_context_get_element ##### -->
237 <!-- ##### FUNCTION g_markup_parse_context_get_element_stack ##### -->
246 <!-- ##### FUNCTION g_markup_parse_context_get_user_data ##### -->
255 <!-- ##### FUNCTION g_markup_parse_context_new ##### -->
267 <!-- ##### FUNCTION g_markup_parse_context_parse ##### -->
279 <!-- ##### FUNCTION g_markup_parse_context_push ##### -->
289 <!-- ##### FUNCTION g_markup_parse_context_pop ##### -->
298 <!-- ##### ENUM GMarkupCollectType ##### -->
303 @G_MARKUP_COLLECT_INVALID:
304 @G_MARKUP_COLLECT_STRING:
305 @G_MARKUP_COLLECT_STRDUP:
306 @G_MARKUP_COLLECT_BOOLEAN:
307 @G_MARKUP_COLLECT_TRISTATE:
308 @G_MARKUP_COLLECT_OPTIONAL:
310 <!-- ##### FUNCTION g_markup_collect_attributes ##### -->