1 <!-- ##### SECTION Title ##### -->
2 Simple XML Subset Parser
4 <!-- ##### SECTION Short_Description ##### -->
8 <!-- ##### SECTION Long_Description ##### -->
10 The "GMarkup" parser is intended to parse a simple markup format
11 that's a subset of XML format. This is a small, efficient, easy-to-use
12 parser. It should not be used if you expect to interoperate with other
13 applications generating full-scale XML. However, it's very useful for
14 application data files, config files, etc. where you know your
15 application will be the only one writing the file. Full-scale XML
16 parsers should be able to parse the subset used by GMarkup, so you can
17 easily migrate to full-scale XML at a later time if the need arises.
21 GMarkup is not guaranteed to signal an error on all invalid XML; the
22 parser may accept documents that an XML parser would not, e.g. the
23 sequence <literal><[[</literal> has special meaning in XML and not
24 in GMarkup. However, invalid XML documents are not considered valid
29 Simplifications to XML include:
33 Only UTF-8 encoding is allowed.
38 No CDATA, no user-defined entities.
43 Processing instructions and comments are "passed through" but are not
44 interpreted in any way.
60 The markup format does support:
74 5 standard entities: <literal>&amp; &lt; &gt; &quot; &apos;</literal>
85 <!-- ##### SECTION See_Also ##### -->
90 <!-- ##### ENUM GMarkupError ##### -->
95 @G_MARKUP_ERROR_BAD_UTF8: text being parsed was not valid UTF-8
96 @G_MARKUP_ERROR_EMPTY: document contained nothing, or only whitespace
97 @G_MARKUP_ERROR_PARSE: document was ill-formed
98 @G_MARKUP_ERROR_UNKNOWN_ELEMENT: error should be set by #GMarkupParser functions; element wasn't known
99 @G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE: error should be set by #GMarkupParser functions; attribute wasn't known
100 @G_MARKUP_ERROR_INVALID_CONTENT: error should be set by #GMarkupParser functions; something was wrong with contents of the document, e.g. invalid attribute value
102 <!-- ##### MACRO G_MARKUP_ERROR ##### -->
109 <!-- ##### ENUM GMarkupParseFlags ##### -->
111 There are no flags right now
114 @G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG:
116 <!-- ##### STRUCT GMarkupParseContext ##### -->
122 <!-- ##### STRUCT GMarkupParser ##### -->
124 Any of the fields in #GMarkupParser can be %NULL, in which case they
125 will be ignored. Except for the @error function, any of these
126 callbacks can set an error; in particular the
127 %G_MARKUP_ERROR_UNKNOWN_ELEMENT, %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
128 and %G_MARKUP_ERROR_INVALID_CONTENT errors are intended to be set
129 from these callbacks. If you set an error from a callback,
130 g_markup_parse_context_parse() will report that error back to its caller.
133 @start_element: Callback to invoke when the opening tag of an element
135 @end_element: Callback to invoke when the closing tag of an element is seen
136 @text: Callback to invoke when some text is seen (text is always
138 @passthrough: Callback to invoke for comments and processing
139 instructions; if you're re-writing the parsed document, write the
140 passthrough text back out in the same position
141 @error: Callback to invoke when an error occurs
143 <!-- ##### FUNCTION g_markup_escape_text ##### -->
153 <!-- ##### FUNCTION g_markup_parse_context_end_parse ##### -->
163 <!-- ##### FUNCTION g_markup_parse_context_free ##### -->
171 <!-- ##### FUNCTION g_markup_parse_context_get_position ##### -->
181 <!-- ##### FUNCTION g_markup_parse_context_new ##### -->
193 <!-- ##### FUNCTION g_markup_parse_context_parse ##### -->