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 <!-- ##### SECTION Image ##### -->
98 <!-- ##### ENUM GMarkupError ##### -->
100 Error codes returned by markup parsing.
103 @G_MARKUP_ERROR_BAD_UTF8: text being parsed was not valid UTF-8
104 @G_MARKUP_ERROR_EMPTY: document contained nothing, or only whitespace
105 @G_MARKUP_ERROR_PARSE: document was ill-formed
106 @G_MARKUP_ERROR_UNKNOWN_ELEMENT: error should be set by #GMarkupParser functions; element wasn't known
107 @G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE: error should be set by #GMarkupParser functions; attribute wasn't known
108 @G_MARKUP_ERROR_INVALID_CONTENT: error should be set by #GMarkupParser functions; content was invalid
109 @G_MARKUP_ERROR_MISSING_ATTRIBUTE: error should be set by #GMarkupParser functions; a required attribute was missing
111 <!-- ##### MACRO G_MARKUP_ERROR ##### -->
113 Error domain for markup parsing. Errors in this domain will
114 be from the #GMarkupError enumeration. See #GError for information on
120 <!-- ##### ENUM GMarkupParseFlags ##### -->
122 Flags that affect the behaviour of the parser.
125 @G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG: flag you should not use.
126 @G_MARKUP_TREAT_CDATA_AS_TEXT: When this flag is set, CDATA marked
127 sections are not passed literally to the @passthrough function of
128 the parser. Instead, the content of the section (without the
129 <literal><![CDATA[</literal> and <literal>]]></literal>) is
130 passed to the @text function. This flag was added in GLib 2.12.
131 @G_MARKUP_PREFIX_ERROR_POSITION: Normally errors caught by GMarkup
132 itself have line/column information prefixed to them to let the
133 caller know the location of the error. When this flag is set the
134 location information is also prefixed to errors generated by the
135 #GMarkupParser implementation functions.
137 <!-- ##### STRUCT GMarkupParseContext ##### -->
139 A parse context is used to parse a stream of bytes that you expect to
140 contain marked-up text. See g_markup_parse_context_new(),
141 #GMarkupParser, and so on for more details.
145 <!-- ##### STRUCT GMarkupParser ##### -->
147 Any of the fields in #GMarkupParser can be %NULL, in which case they
148 will be ignored. Except for the @error function, any of these
149 callbacks can set an error; in particular the
150 %G_MARKUP_ERROR_UNKNOWN_ELEMENT, %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
151 and %G_MARKUP_ERROR_INVALID_CONTENT errors are intended to be set
152 from these callbacks. If you set an error from a callback,
153 g_markup_parse_context_parse() will report that error back to its caller.
156 @start_element: Callback to invoke when the opening tag of an element
158 @end_element: Callback to invoke when the closing tag of an element is seen.
159 Note that this is also called for empty tags like
160 <literal><empty/></literal>.
161 @text: Callback to invoke when some text is seen (text is always
162 inside an element). Note that the text of an element may be spread
163 over multiple calls of this function. If the %G_MARKUP_TREAT_CDATA_AS_TEXT
164 flag is set, this function is also called for the content of CDATA marked
166 @passthrough: Callback to invoke for comments, processing instructions
167 and doctype declarations; if you're re-writing the parsed document,
168 write the passthrough text back out in the same position. If the
169 %G_MARKUP_TREAT_CDATA_AS_TEXT flag is not set, this function is also
170 called for CDATA marked sections.
171 @error: Callback to invoke when an error occurs.
173 <!-- ##### FUNCTION g_markup_escape_text ##### -->
183 <!-- ##### FUNCTION g_markup_printf_escaped ##### -->
193 <!-- ##### FUNCTION g_markup_vprintf_escaped ##### -->
203 <!-- ##### FUNCTION g_markup_parse_context_end_parse ##### -->
213 <!-- ##### FUNCTION g_markup_parse_context_free ##### -->
221 <!-- ##### FUNCTION g_markup_parse_context_get_position ##### -->
231 <!-- ##### FUNCTION g_markup_parse_context_get_element ##### -->
240 <!-- ##### FUNCTION g_markup_parse_context_get_element_stack ##### -->
249 <!-- ##### FUNCTION g_markup_parse_context_get_user_data ##### -->
258 <!-- ##### FUNCTION g_markup_parse_context_new ##### -->
270 <!-- ##### FUNCTION g_markup_parse_context_parse ##### -->
282 <!-- ##### FUNCTION g_markup_parse_context_push ##### -->
292 <!-- ##### FUNCTION g_markup_parse_context_pop ##### -->
301 <!-- ##### ENUM GMarkupCollectType ##### -->
306 @G_MARKUP_COLLECT_INVALID:
307 @G_MARKUP_COLLECT_STRING:
308 @G_MARKUP_COLLECT_STRDUP:
309 @G_MARKUP_COLLECT_BOOLEAN:
310 @G_MARKUP_COLLECT_TRISTATE:
311 @G_MARKUP_COLLECT_OPTIONAL:
313 <!-- ##### FUNCTION g_markup_collect_attributes ##### -->