<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC '-//OASIS//DTD DocBook XML V4.5//EN'
                      'http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd' [
<!ENTITY % local.common.attrib "xmlns:xi  CDATA  #FIXED 'http://www.w3.org/2003/XInclude'">
<!ENTITY version SYSTEM "version.xml">
]>
<refentry id="glib-Simple-XML-Subset-Parser">
<refmeta>
<refentrytitle role="top_of_page" id="glib-Simple-XML-Subset-Parser.top_of_page">Simple XML Subset Parser</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GLIB Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Simple XML Subset Parser</refname>
<refpurpose>parses a subset of XML</refpurpose>
</refnamediv>

<refsect1 id="glib-Simple-XML-Subset-Parser.functions" role="functions_proto">
<title role="functions_proto.title">Functions</title>
<informaltable pgwide="1" frame="none">
<tgroup cols="2">
<colspec colname="functions_proto_type" colwidth="150px"/>
<colspec colname="functions_proto_name"/>
<tbody>
<row><entry role="function_type"><link linkend="gchar"><returnvalue>gchar</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-markup-escape-text">g_markup_escape_text</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gchar"><returnvalue>gchar</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-markup-printf-escaped">g_markup_printf_escaped</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gchar"><returnvalue>gchar</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-markup-vprintf-escaped">g_markup_vprintf_escaped</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GMarkupParseContext"><returnvalue>GMarkupParseContext</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-markup-parse-context-new">g_markup_parse_context_new</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-markup-parse-context-parse">g_markup_parse_context_parse</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-markup-parse-context-end-parse">g_markup_parse_context_end_parse</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-markup-parse-context-free">g_markup_parse_context_free</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-markup-parse-context-get-position">g_markup_parse_context_get_position</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type">const <link linkend="gchar"><returnvalue>gchar</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-markup-parse-context-get-element">g_markup_parse_context_get_element</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type">const <link linkend="GSList"><returnvalue>GSList</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-markup-parse-context-get-element-stack">g_markup_parse_context_get_element_stack</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gpointer"><returnvalue>gpointer</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-markup-parse-context-get-user-data">g_markup_parse_context_get_user_data</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-markup-parse-context-push">g_markup_parse_context_push</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gpointer"><returnvalue>gpointer</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-markup-parse-context-pop">g_markup_parse_context_pop</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GMarkupParseContext"><returnvalue>GMarkupParseContext</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-markup-parse-context-ref">g_markup_parse_context_ref</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-markup-parse-context-unref">g_markup_parse_context_unref</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>

<row><entry role="function_type"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-markup-collect-attributes">g_markup_collect_attributes</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 id="glib-Simple-XML-Subset-Parser.other" role="other_proto">
<title role="other_proto.title">Types and Values</title>
<informaltable pgwide="1" frame="none">
<tgroup cols="2">
<colspec colname="other_proto_type" colwidth="150px"/>
<colspec colname="other_proto_name"/>
<tbody>
<row><entry role="datatype_keyword">enum</entry><entry role="function_name"><link linkend="GMarkupError">GMarkupError</link></entry></row>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="G-MARKUP-ERROR:CAPS">G_MARKUP_ERROR</link></entry></row>
<row><entry role="datatype_keyword">enum</entry><entry role="function_name"><link linkend="GMarkupParseFlags">GMarkupParseFlags</link></entry></row>
<row><entry role="datatype_keyword"></entry><entry role="function_name"><link linkend="GMarkupParseContext">GMarkupParseContext</link></entry></row>
<row><entry role="datatype_keyword">struct</entry><entry role="function_name"><link linkend="GMarkupParser">GMarkupParser</link></entry></row>

<row><entry role="datatype_keyword">enum</entry><entry role="function_name"><link linkend="GMarkupCollectType">GMarkupCollectType</link></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>

<refsect1 id="glib-Simple-XML-Subset-Parser.includes"><title>Includes</title><synopsis>#include &lt;glib.h&gt;
</synopsis></refsect1>

<refsect1 id="glib-Simple-XML-Subset-Parser.description" role="desc">
<title role="desc.title">Description</title>
<para>The "GMarkup" parser is intended to parse a simple markup format
that's a subset of XML. This is a small, efficient, easy-to-use
parser. It should not be used if you expect to interoperate with
other applications generating full-scale XML, and must not be used if you
expect to parse untrusted input. However, it's very
useful for application data files, config files, etc. where you
know your application will be the only one writing the file.
Full-scale XML parsers should be able to parse the subset used by
GMarkup, so you can easily migrate to full-scale XML at a later
time if the need arises.</para>
<para>GMarkup is not guaranteed to signal an error on all invalid XML;
the parser may accept documents that an XML parser would not.
However, XML documents which are not well-formed (which is a
weaker condition than being valid. See the
<ulink url="http://www.w3.org/TR/REC-xml/">XML specification</ulink>
for definitions of these terms.) are not considered valid GMarkup
documents.</para>
<para>Simplifications to XML include:</para>
<itemizedlist>
<listitem>
<para>Only UTF-8 encoding is allowed</para>
</listitem>
<listitem>
<para>No user-defined entities</para>
</listitem>
<listitem>
<para>Processing instructions, comments and the doctype declaration
are "passed through" but are not interpreted in any way</para>
</listitem>
<listitem>
<para>No DTD or validation</para>
</listitem>
</itemizedlist>
<para>The markup format does support:</para>
<itemizedlist>
<listitem>
<para>Elements</para>
</listitem>
<listitem>
<para>Attributes</para>
</listitem>
<listitem>
<para>5 standard entities: &amp; &lt; &gt; &quot; &apos;</para>
</listitem>
<listitem>
<para>Character references</para>
</listitem>
<listitem><para>Sections marked as CDATA</para></listitem>
</itemizedlist>

</refsect1>
<refsect1 id="glib-Simple-XML-Subset-Parser.functions_details" role="details">
<title role="details.title">Functions</title>
<refsect2 id="g-markup-escape-text" role="function">
<title>g_markup_escape_text&#160;()</title>
<indexterm zone="g-markup-escape-text"><primary sortas="markup_escape_text">g_markup_escape_text</primary></indexterm>
<programlisting language="C"><link linkend="gchar"><returnvalue>gchar</returnvalue></link>&#160;*
g_markup_escape_text (<parameter>const <link linkend="gchar"><type>gchar</type></link> *text</parameter>,
                      <parameter><link linkend="gssize"><type>gssize</type></link> length</parameter>);</programlisting>
<para>Escapes text so that the markup parser will parse it verbatim.
Less than, greater than, ampersand, etc. are replaced with the
corresponding entities. This function would typically be used
when writing out a file to be parsed with the markup parser.</para>
<para>Note that this function doesn't protect whitespace and line endings
from being processed according to the XML rules for normalization
of line endings and attribute values.</para>
<para>Note also that this function will produce character references in
the range of &amp;<link linkend="x1"><type>x1</type></link>; ... &amp;<link linkend="x1f"><type>x1f</type></link>; for all control sequences
except for tabstop, newline and carriage return.  The character
references in this range are not valid XML 1.0, but they are
valid XML 1.1 and will be accepted by the GMarkup parser.</para>
<refsect3 id="g-markup-escape-text.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>text</para></entry>
<entry role="parameter_description"><para>some valid UTF-8 text</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>length</para></entry>
<entry role="parameter_description"><para>length of <parameter>text</parameter>
in bytes, or -1 if the text is nul-terminated</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-markup-escape-text.returns" role="returns">
<title>Returns</title>
<para> a newly allocated string with the escaped text</para>
</refsect3></refsect2>
<refsect2 id="g-markup-printf-escaped" role="function" condition="since:2.4">
<title>g_markup_printf_escaped&#160;()</title>
<indexterm zone="g-markup-printf-escaped" role="2.4"><primary sortas="markup_printf_escaped">g_markup_printf_escaped</primary></indexterm>
<programlisting language="C"><link linkend="gchar"><returnvalue>gchar</returnvalue></link>&#160;*
g_markup_printf_escaped (<parameter>const <link linkend="char"><type>char</type></link> *format</parameter>,
                         <parameter>...</parameter>);</programlisting>
<para>Formats arguments according to <parameter>format</parameter>
, escaping
all string and character arguments in the fashion
of <link linkend="g-markup-escape-text"><function>g_markup_escape_text()</function></link>. This is useful when you
want to insert literal strings into XML-style markup
output, without having to worry that the strings
might themselves contain markup.</para>
<informalexample><programlisting role="example"><![CDATA[
const char *store = "Fortnum & Mason";
const char *item = "Tea";
char *output;

output = g_markup_printf_escaped ("<purchase>"
                                  "<store>%s</store>"
                                  "<item>%s</item>"
                                  "</purchase>",
                                  store, item);
]]></programlisting></informalexample>
<para></para>
<refsect3 id="g-markup-printf-escaped.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>format</para></entry>
<entry role="parameter_description"><para>printf() style format string</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>...</para></entry>
<entry role="parameter_description"><para>the arguments to insert in the format string</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-markup-printf-escaped.returns" role="returns">
<title>Returns</title>
<para> newly allocated result from formatting
operation. Free with <link linkend="g-free"><function>g_free()</function></link>.</para>
</refsect3><para role="since">Since: <link linkend="api-index-2.4">2.4</link></para></refsect2>
<refsect2 id="g-markup-vprintf-escaped" role="function" condition="since:2.4">
<title>g_markup_vprintf_escaped&#160;()</title>
<indexterm zone="g-markup-vprintf-escaped" role="2.4"><primary sortas="markup_vprintf_escaped">g_markup_vprintf_escaped</primary></indexterm>
<programlisting language="C"><link linkend="gchar"><returnvalue>gchar</returnvalue></link>&#160;*
g_markup_vprintf_escaped (<parameter>const <link linkend="char"><type>char</type></link> *format</parameter>,
                          <parameter><link linkend="va-list"><type>va_list</type></link> args</parameter>);</programlisting>
<para>Formats the data in <parameter>args</parameter>
 according to <parameter>format</parameter>
, escaping
all string and character arguments in the fashion
of <link linkend="g-markup-escape-text"><function>g_markup_escape_text()</function></link>. See <link linkend="g-markup-printf-escaped"><function>g_markup_printf_escaped()</function></link>.</para>
<refsect3 id="g-markup-vprintf-escaped.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>format</para></entry>
<entry role="parameter_description"><para>printf() style format string</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>args</para></entry>
<entry role="parameter_description"><para>variable argument list, similar to <link linkend="vprintf"><function>vprintf()</function></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-markup-vprintf-escaped.returns" role="returns">
<title>Returns</title>
<para> newly allocated result from formatting
operation. Free with <link linkend="g-free"><function>g_free()</function></link>.</para>
</refsect3><para role="since">Since: <link linkend="api-index-2.4">2.4</link></para></refsect2>
<refsect2 id="g-markup-parse-context-new" role="function">
<title>g_markup_parse_context_new&#160;()</title>
<indexterm zone="g-markup-parse-context-new"><primary sortas="markup_parse_context_new">g_markup_parse_context_new</primary></indexterm>
<programlisting language="C"><link linkend="GMarkupParseContext"><returnvalue>GMarkupParseContext</returnvalue></link>&#160;*
g_markup_parse_context_new (<parameter>const <link linkend="GMarkupParser"><type>GMarkupParser</type></link> *parser</parameter>,
                            <parameter><link linkend="GMarkupParseFlags"><type>GMarkupParseFlags</type></link> flags</parameter>,
                            <parameter><link linkend="gpointer"><type>gpointer</type></link> user_data</parameter>,
                            <parameter><link linkend="GDestroyNotify"><type>GDestroyNotify</type></link> user_data_dnotify</parameter>);</programlisting>
<para>Creates a new parse context. A parse context is used to parse
marked-up documents. You can feed any number of documents into
a context, as long as no errors occur; once an error occurs,
the parse context can't continue to parse text (you have to
free it and create a new parse context).</para>
<refsect3 id="g-markup-parse-context-new.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>parser</para></entry>
<entry role="parameter_description"><para>a <link linkend="GMarkupParser"><type>GMarkupParser</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>flags</para></entry>
<entry role="parameter_description"><para>one or more <link linkend="GMarkupParseFlags"><type>GMarkupParseFlags</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>user_data</para></entry>
<entry role="parameter_description"><para>user data to pass to <link linkend="GMarkupParser"><type>GMarkupParser</type></link> functions</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>user_data_dnotify</para></entry>
<entry role="parameter_description"><para>user data destroy notifier called when
the parse context is freed</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-markup-parse-context-new.returns" role="returns">
<title>Returns</title>
<para> a new <link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link></para>
</refsect3></refsect2>
<refsect2 id="g-markup-parse-context-parse" role="function">
<title>g_markup_parse_context_parse&#160;()</title>
<indexterm zone="g-markup-parse-context-parse"><primary sortas="markup_parse_context_parse">g_markup_parse_context_parse</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
g_markup_parse_context_parse (<parameter><link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link> *context</parameter>,
                              <parameter>const <link linkend="gchar"><type>gchar</type></link> *text</parameter>,
                              <parameter><link linkend="gssize"><type>gssize</type></link> text_len</parameter>,
                              <parameter><link linkend="GError"><type>GError</type></link> **error</parameter>);</programlisting>
<para>Feed some data to the <link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link>.</para>
<para>The data need not be valid UTF-8; an error will be signaled if
it's invalid. The data need not be an entire document; you can
feed a document into the parser incrementally, via multiple calls
to this function. Typically, as you receive data from a network
connection or file, you feed each received chunk of data into this
function, aborting the process if an error occurs. Once an error
is reported, no further data may be fed to the <link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link>;
all errors are fatal.</para>
<refsect3 id="g-markup-parse-context-parse.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>context</para></entry>
<entry role="parameter_description"><para>a <link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>text</para></entry>
<entry role="parameter_description"><para>chunk of text to parse</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>text_len</para></entry>
<entry role="parameter_description"><para>length of <parameter>text</parameter>
in bytes</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>error</para></entry>
<entry role="parameter_description"><para>return location for a <link linkend="GError"><type>GError</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-markup-parse-context-parse.returns" role="returns">
<title>Returns</title>
<para> <link linkend="FALSE:CAPS"><literal>FALSE</literal></link> if an error occurred, <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> on success</para>
</refsect3></refsect2>
<refsect2 id="g-markup-parse-context-end-parse" role="function">
<title>g_markup_parse_context_end_parse&#160;()</title>
<indexterm zone="g-markup-parse-context-end-parse"><primary sortas="markup_parse_context_end_parse">g_markup_parse_context_end_parse</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
g_markup_parse_context_end_parse (<parameter><link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link> *context</parameter>,
                                  <parameter><link linkend="GError"><type>GError</type></link> **error</parameter>);</programlisting>
<para>Signals to the <link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link> that all data has been
fed into the parse context with <link linkend="g-markup-parse-context-parse"><function>g_markup_parse_context_parse()</function></link>.</para>
<para>This function reports an error if the document isn't complete,
for example if elements are still open.</para>
<refsect3 id="g-markup-parse-context-end-parse.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>context</para></entry>
<entry role="parameter_description"><para>a <link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>error</para></entry>
<entry role="parameter_description"><para>return location for a <link linkend="GError"><type>GError</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-markup-parse-context-end-parse.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> on success, <link linkend="FALSE:CAPS"><literal>FALSE</literal></link> if an error was set</para>
</refsect3></refsect2>
<refsect2 id="g-markup-parse-context-free" role="function">
<title>g_markup_parse_context_free&#160;()</title>
<indexterm zone="g-markup-parse-context-free"><primary sortas="markup_parse_context_free">g_markup_parse_context_free</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
g_markup_parse_context_free (<parameter><link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link> *context</parameter>);</programlisting>
<para>Frees a <link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link>.</para>
<para>This function can't be called from inside one of the
<link linkend="GMarkupParser"><type>GMarkupParser</type></link> functions or while a subparser is pushed.</para>
<refsect3 id="g-markup-parse-context-free.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>context</para></entry>
<entry role="parameter_description"><para>a <link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="g-markup-parse-context-get-position" role="function">
<title>g_markup_parse_context_get_position&#160;()</title>
<indexterm zone="g-markup-parse-context-get-position"><primary sortas="markup_parse_context_get_position">g_markup_parse_context_get_position</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
g_markup_parse_context_get_position (<parameter><link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link> *context</parameter>,
                                     <parameter><link linkend="gint"><type>gint</type></link> *line_number</parameter>,
                                     <parameter><link linkend="gint"><type>gint</type></link> *char_number</parameter>);</programlisting>
<para>Retrieves the current line number and the number of the character on
that line. Intended for use in error messages; there are no strict
semantics for what constitutes the "current" line number other than
"the best number we could come up with for error messages."</para>
<refsect3 id="g-markup-parse-context-get-position.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>context</para></entry>
<entry role="parameter_description"><para>a <link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>line_number</para></entry>
<entry role="parameter_description"><para>return location for a line number, or <link linkend="NULL:CAPS"><literal>NULL</literal></link>. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>nullable</acronym>]</emphasis></entry></row>
<row><entry role="parameter_name"><para>char_number</para></entry>
<entry role="parameter_description"><para>return location for a char-on-line number, or <link linkend="NULL:CAPS"><literal>NULL</literal></link>. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>nullable</acronym>]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="g-markup-parse-context-get-element" role="function" condition="since:2.2">
<title>g_markup_parse_context_get_element&#160;()</title>
<indexterm zone="g-markup-parse-context-get-element" role="2.2"><primary sortas="markup_parse_context_get_element">g_markup_parse_context_get_element</primary></indexterm>
<programlisting language="C">const <link linkend="gchar"><returnvalue>gchar</returnvalue></link>&#160;*
g_markup_parse_context_get_element (<parameter><link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link> *context</parameter>);</programlisting>
<para>Retrieves the name of the currently open element.</para>
<para>If called from the start_element or end_element handlers this will
give the element_name as passed to those functions. For the parent
elements, see <link linkend="g-markup-parse-context-get-element-stack"><function>g_markup_parse_context_get_element_stack()</function></link>.</para>
<refsect3 id="g-markup-parse-context-get-element.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>context</para></entry>
<entry role="parameter_description"><para>a <link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-markup-parse-context-get-element.returns" role="returns">
<title>Returns</title>
<para> the name of the currently open element, or <link linkend="NULL:CAPS"><literal>NULL</literal></link></para>
</refsect3><para role="since">Since: <link linkend="api-index-2.2">2.2</link></para></refsect2>
<refsect2 id="g-markup-parse-context-get-element-stack" role="function" condition="since:2.16">
<title>g_markup_parse_context_get_element_stack&#160;()</title>
<indexterm zone="g-markup-parse-context-get-element-stack" role="2.16"><primary sortas="markup_parse_context_get_element_stack">g_markup_parse_context_get_element_stack</primary></indexterm>
<programlisting language="C">const <link linkend="GSList"><returnvalue>GSList</returnvalue></link>&#160;*
g_markup_parse_context_get_element_stack
                               (<parameter><link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link> *context</parameter>);</programlisting>
<para>Retrieves the element stack from the internal state of the parser.</para>
<para>The returned <link linkend="GSList"><type>GSList</type></link> is a list of strings where the first item is
the currently open tag (as would be returned by
<link linkend="g-markup-parse-context-get-element"><function>g_markup_parse_context_get_element()</function></link>) and the next item is its
immediate parent.</para>
<para>This function is intended to be used in the start_element and
end_element handlers where <link linkend="g-markup-parse-context-get-element"><function>g_markup_parse_context_get_element()</function></link>
would merely return the name of the element that is being
processed.</para>
<refsect3 id="g-markup-parse-context-get-element-stack.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>context</para></entry>
<entry role="parameter_description"><para>a <link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-markup-parse-context-get-element-stack.returns" role="returns">
<title>Returns</title>
<para> the element stack, which must not be modified</para>
</refsect3><para role="since">Since: <link linkend="api-index-2.16">2.16</link></para></refsect2>
<refsect2 id="g-markup-parse-context-get-user-data" role="function" condition="since:2.18">
<title>g_markup_parse_context_get_user_data&#160;()</title>
<indexterm zone="g-markup-parse-context-get-user-data" role="2.18"><primary sortas="markup_parse_context_get_user_data">g_markup_parse_context_get_user_data</primary></indexterm>
<programlisting language="C"><link linkend="gpointer"><returnvalue>gpointer</returnvalue></link>
g_markup_parse_context_get_user_data (<parameter><link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link> *context</parameter>);</programlisting>
<para>Returns the user_data associated with <parameter>context</parameter>
.</para>
<para>This will either be the user_data that was provided to
<link linkend="g-markup-parse-context-new"><function>g_markup_parse_context_new()</function></link> or to the most recent call
of <link linkend="g-markup-parse-context-push"><function>g_markup_parse_context_push()</function></link>.</para>
<refsect3 id="g-markup-parse-context-get-user-data.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>context</para></entry>
<entry role="parameter_description"><para>a <link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-markup-parse-context-get-user-data.returns" role="returns">
<title>Returns</title>
<para> the provided user_data. The returned data belongs to
the markup context and will be freed when
<link linkend="g-markup-parse-context-free"><function>g_markup_parse_context_free()</function></link> is called.</para>
</refsect3><para role="since">Since: <link linkend="api-index-2.18">2.18</link></para></refsect2>
<refsect2 id="g-markup-parse-context-push" role="function" condition="since:2.18">
<title>g_markup_parse_context_push&#160;()</title>
<indexterm zone="g-markup-parse-context-push" role="2.18"><primary sortas="markup_parse_context_push">g_markup_parse_context_push</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
g_markup_parse_context_push (<parameter><link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link> *context</parameter>,
                             <parameter>const <link linkend="GMarkupParser"><type>GMarkupParser</type></link> *parser</parameter>,
                             <parameter><link linkend="gpointer"><type>gpointer</type></link> user_data</parameter>);</programlisting>
<para>Temporarily redirects markup data to a sub-parser.</para>
<para>This function may only be called from the start_element handler of
a <link linkend="GMarkupParser"><type>GMarkupParser</type></link>. It must be matched with a corresponding call to
<link linkend="g-markup-parse-context-pop"><function>g_markup_parse_context_pop()</function></link> in the matching end_element handler
(except in the case that the parser aborts due to an error).</para>
<para>All tags, text and other data between the matching tags is
redirected to the subparser given by <parameter>parser</parameter>
. <parameter>user_data</parameter>
 is used
as the user_data for that parser. <parameter>user_data</parameter>
 is also passed to the
error callback in the event that an error occurs. This includes
errors that occur in subparsers of the subparser.</para>
<para>The end tag matching the start tag for which this call was made is
handled by the previous parser (which is given its own user_data)
which is why <link linkend="g-markup-parse-context-pop"><function>g_markup_parse_context_pop()</function></link> is provided to allow "one
last access" to the <parameter>user_data</parameter>
 provided to this function. In the
case of error, the <parameter>user_data</parameter>
 provided here is passed directly to
the error callback of the subparser and <link linkend="g-markup-parse-context-pop"><function>g_markup_parse_context_pop()</function></link>
should not be called. In either case, if <parameter>user_data</parameter>
 was allocated
then it ought to be freed from both of these locations.</para>
<para>This function is not intended to be directly called by users
interested in invoking subparsers. Instead, it is intended to be
used by the subparsers themselves to implement a higher-level
interface.</para>
<para>As an example, see the following implementation of a simple
parser that counts the number of tags encountered.</para>
<informalexample><programlisting role="example"><![CDATA[
typedef struct
{
  gint tag_count;
} CounterData;

static void
counter_start_element (GMarkupParseContext  *context,
                       const gchar          *element_name,
                       const gchar         **attribute_names,
                       const gchar         **attribute_values,
                       gpointer              user_data,
                       GError              **error)
{
  CounterData *data = user_data;

  data->tag_count++;
}

static void
counter_error (GMarkupParseContext *context,
               GError              *error,
               gpointer             user_data)
{
  CounterData *data = user_data;

  g_slice_free (CounterData, data);
}

static GMarkupParser counter_subparser =
{
  counter_start_element,
  NULL,
  NULL,
  NULL,
  counter_error
};
]]></programlisting></informalexample>
<para></para>
<para>In order to allow this parser to be easily used as a subparser, the
following interface is provided:</para>
<informalexample><programlisting role="example"><![CDATA[
void
start_counting (GMarkupParseContext *context)
{
  CounterData *data = g_slice_new (CounterData);

  data->tag_count = 0;
  g_markup_parse_context_push (context, &counter_subparser, data);
}

gint
end_counting (GMarkupParseContext *context)
{
  CounterData *data = g_markup_parse_context_pop (context);
  int result;

  result = data->tag_count;
  g_slice_free (CounterData, data);

  return result;
}
]]></programlisting></informalexample>
<para></para>
<para>The subparser would then be used as follows:</para>
<informalexample><programlisting role="example"><![CDATA[
static void start_element (context, element_name, ...)
{
  if (strcmp (element_name, "count-these") == 0)
    start_counting (context);

  // else, handle other tags...
}

static void end_element (context, element_name, ...)
{
  if (strcmp (element_name, "count-these") == 0)
    g_print ("Counted %d tags\n", end_counting (context));

  // else, handle other tags...
}
]]></programlisting></informalexample>
<para></para>
<refsect3 id="g-markup-parse-context-push.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>context</para></entry>
<entry role="parameter_description"><para>a <link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>parser</para></entry>
<entry role="parameter_description"><para>a <link linkend="GMarkupParser"><type>GMarkupParser</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>user_data</para></entry>
<entry role="parameter_description"><para>user data to pass to <link linkend="GMarkupParser"><type>GMarkupParser</type></link> functions</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><para role="since">Since: <link linkend="api-index-2.18">2.18</link></para></refsect2>
<refsect2 id="g-markup-parse-context-pop" role="function" condition="since:2.18">
<title>g_markup_parse_context_pop&#160;()</title>
<indexterm zone="g-markup-parse-context-pop" role="2.18"><primary sortas="markup_parse_context_pop">g_markup_parse_context_pop</primary></indexterm>
<programlisting language="C"><link linkend="gpointer"><returnvalue>gpointer</returnvalue></link>
g_markup_parse_context_pop (<parameter><link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link> *context</parameter>);</programlisting>
<para>Completes the process of a temporary sub-parser redirection.</para>
<para>This function exists to collect the user_data allocated by a
matching call to <link linkend="g-markup-parse-context-push"><function>g_markup_parse_context_push()</function></link>. It must be called
in the end_element handler corresponding to the start_element
handler during which <link linkend="g-markup-parse-context-push"><function>g_markup_parse_context_push()</function></link> was called.
You must not call this function from the error callback -- the
<parameter>user_data</parameter>
 is provided directly to the callback in that case.</para>
<para>This function is not intended to be directly called by users
interested in invoking subparsers. Instead, it is intended to
be used by the subparsers themselves to implement a higher-level
interface.</para>
<refsect3 id="g-markup-parse-context-pop.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>context</para></entry>
<entry role="parameter_description"><para>a <link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-markup-parse-context-pop.returns" role="returns">
<title>Returns</title>
<para> the user data passed to <link linkend="g-markup-parse-context-push"><function>g_markup_parse_context_push()</function></link></para>
</refsect3><para role="since">Since: <link linkend="api-index-2.18">2.18</link></para></refsect2>
<refsect2 id="g-markup-parse-context-ref" role="function" condition="since:2.36">
<title>g_markup_parse_context_ref&#160;()</title>
<indexterm zone="g-markup-parse-context-ref" role="2.36"><primary sortas="markup_parse_context_ref">g_markup_parse_context_ref</primary></indexterm>
<programlisting language="C"><link linkend="GMarkupParseContext"><returnvalue>GMarkupParseContext</returnvalue></link>&#160;*
g_markup_parse_context_ref (<parameter><link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link> *context</parameter>);</programlisting>
<para>Increases the reference count of <parameter>context</parameter>
.</para>
<refsect3 id="g-markup-parse-context-ref.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>context</para></entry>
<entry role="parameter_description"><para>a <link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-markup-parse-context-ref.returns" role="returns">
<title>Returns</title>
<para> the same <parameter>context</parameter>
</para>
</refsect3><para role="since">Since: <link linkend="api-index-2.36">2.36</link></para></refsect2>
<refsect2 id="g-markup-parse-context-unref" role="function" condition="since:2.36">
<title>g_markup_parse_context_unref&#160;()</title>
<indexterm zone="g-markup-parse-context-unref" role="2.36"><primary sortas="markup_parse_context_unref">g_markup_parse_context_unref</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
g_markup_parse_context_unref (<parameter><link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link> *context</parameter>);</programlisting>
<para>Decreases the reference count of <parameter>context</parameter>
.  When its reference count
drops to 0, it is freed.</para>
<refsect3 id="g-markup-parse-context-unref.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>context</para></entry>
<entry role="parameter_description"><para>a <link linkend="GMarkupParseContext"><type>GMarkupParseContext</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><para role="since">Since: <link linkend="api-index-2.36">2.36</link></para></refsect2>
<refsect2 id="g-markup-collect-attributes" role="function" condition="since:2.16">
<title>g_markup_collect_attributes&#160;()</title>
<indexterm zone="g-markup-collect-attributes" role="2.16"><primary sortas="markup_collect_attributes">g_markup_collect_attributes</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
g_markup_collect_attributes (<parameter>const <link linkend="gchar"><type>gchar</type></link> *element_name</parameter>,
                             <parameter>const <link linkend="gchar"><type>gchar</type></link> **attribute_names</parameter>,
                             <parameter>const <link linkend="gchar"><type>gchar</type></link> **attribute_values</parameter>,
                             <parameter><link linkend="GError"><type>GError</type></link> **error</parameter>,
                             <parameter><link linkend="GMarkupCollectType"><type>GMarkupCollectType</type></link> first_type</parameter>,
                             <parameter>const <link linkend="gchar"><type>gchar</type></link> *first_attr</parameter>,
                             <parameter>...</parameter>);</programlisting>
<para>Collects the attributes of the element from the data passed to the
<link linkend="GMarkupParser"><type>GMarkupParser</type></link> start_element function, dealing with common error
conditions and supporting boolean values.</para>
<para>This utility function is not required to write a parser but can save
a lot of typing.</para>
<para>The <parameter>element_name</parameter>
, <parameter>attribute_names</parameter>
, <parameter>attribute_values</parameter>
 and <parameter>error</parameter>

parameters passed to the start_element callback should be passed
unmodified to this function.</para>
<para>Following these arguments is a list of "supported" attributes to collect.
It is an error to specify multiple attributes with the same name. If any
attribute not in the list appears in the <parameter>attribute_names</parameter>
 array then an
unknown attribute error will result.</para>
<para>The <link linkend="GMarkupCollectType"><type>GMarkupCollectType</type></link> field allows specifying the type of collection
to perform and if a given attribute must appear or is optional.</para>
<para>The attribute name is simply the name of the attribute to collect.</para>
<para>The pointer should be of the appropriate type (see the descriptions
under <link linkend="GMarkupCollectType"><type>GMarkupCollectType</type></link>) and may be <link linkend="NULL:CAPS"><literal>NULL</literal></link> in case a particular
attribute is to be allowed but ignored.</para>
<para>This function deals with issuing errors for missing attributes
(of type <link linkend="G-MARKUP-ERROR-MISSING-ATTRIBUTE:CAPS"><literal>G_MARKUP_ERROR_MISSING_ATTRIBUTE</literal></link>), unknown attributes
(of type <link linkend="G-MARKUP-ERROR-UNKNOWN-ATTRIBUTE:CAPS"><literal>G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE</literal></link>) and duplicate
attributes (of type <link linkend="G-MARKUP-ERROR-INVALID-CONTENT:CAPS"><literal>G_MARKUP_ERROR_INVALID_CONTENT</literal></link>) as well
as parse errors for boolean-valued attributes (again of type
<link linkend="G-MARKUP-ERROR-INVALID-CONTENT:CAPS"><literal>G_MARKUP_ERROR_INVALID_CONTENT</literal></link>). In all of these cases <link linkend="FALSE:CAPS"><literal>FALSE</literal></link>
will be returned and <parameter>error</parameter>
 will be set as appropriate.</para>
<refsect3 id="g-markup-collect-attributes.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>element_name</para></entry>
<entry role="parameter_description"><para>the current tag name</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>attribute_names</para></entry>
<entry role="parameter_description"><para>the attribute names</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>attribute_values</para></entry>
<entry role="parameter_description"><para>the attribute values</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>error</para></entry>
<entry role="parameter_description"><para>a pointer to a <link linkend="GError"><type>GError</type></link> or <link linkend="NULL:CAPS"><literal>NULL</literal></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>first_type</para></entry>
<entry role="parameter_description"><para>the <link linkend="GMarkupCollectType"><type>GMarkupCollectType</type></link> of the first attribute</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>first_attr</para></entry>
<entry role="parameter_description"><para>the name of the first attribute</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>...</para></entry>
<entry role="parameter_description"><para>a pointer to the storage location of the first attribute
(or <link linkend="NULL:CAPS"><literal>NULL</literal></link>), followed by more types names and pointers, ending
with <link linkend="G-MARKUP-COLLECT-INVALID:CAPS"><literal>G_MARKUP_COLLECT_INVALID</literal></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-markup-collect-attributes.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if successful</para>
</refsect3><para role="since">Since: <link linkend="api-index-2.16">2.16</link></para></refsect2>

</refsect1>
<refsect1 id="glib-Simple-XML-Subset-Parser.other_details" role="details">
<title role="details.title">Types and Values</title>
<refsect2 id="GMarkupError" role="enum">
<title>enum GMarkupError</title>
<indexterm zone="GMarkupError"><primary sortas="MarkupError">GMarkupError</primary></indexterm>
<para>Error codes returned by markup parsing.</para>
<refsect3 id="GMarkupError.members" role="enum_members">
<title>Members</title>
<informaltable role="enum_members_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="enum_members_name" colwidth="300px"/>
<colspec colname="enum_members_description"/>
<colspec colname="enum_members_annotations" colwidth="200px"/>
<tbody>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-ERROR-BAD-UTF8:CAPS">G_MARKUP_ERROR_BAD_UTF8</para></entry>
<entry role="enum_member_description"><para>text being parsed was not valid UTF-8</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-ERROR-EMPTY:CAPS">G_MARKUP_ERROR_EMPTY</para></entry>
<entry role="enum_member_description"><para>document contained nothing, or only whitespace</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-ERROR-PARSE:CAPS">G_MARKUP_ERROR_PARSE</para></entry>
<entry role="enum_member_description"><para>document was ill-formed</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-ERROR-UNKNOWN-ELEMENT:CAPS">G_MARKUP_ERROR_UNKNOWN_ELEMENT</para></entry>
<entry role="enum_member_description"><para>error should be set by <link linkend="GMarkupParser"><type>GMarkupParser</type></link>
functions; element wasn't known</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-ERROR-UNKNOWN-ATTRIBUTE:CAPS">G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE</para></entry>
<entry role="enum_member_description"><para>error should be set by <link linkend="GMarkupParser"><type>GMarkupParser</type></link>
functions; attribute wasn't known</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-ERROR-INVALID-CONTENT:CAPS">G_MARKUP_ERROR_INVALID_CONTENT</para></entry>
<entry role="enum_member_description"><para>error should be set by <link linkend="GMarkupParser"><type>GMarkupParser</type></link>
functions; content was invalid</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-ERROR-MISSING-ATTRIBUTE:CAPS">G_MARKUP_ERROR_MISSING_ATTRIBUTE</para></entry>
<entry role="enum_member_description"><para>error should be set by <link linkend="GMarkupParser"><type>GMarkupParser</type></link>
functions; a required attribute was missing</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="G-MARKUP-ERROR:CAPS" role="macro">
<title>G_MARKUP_ERROR</title>
<indexterm zone="G-MARKUP-ERROR:CAPS"><primary sortas="MARKUP_ERROR">G_MARKUP_ERROR</primary></indexterm>
<programlisting language="C">#define G_MARKUP_ERROR g_markup_error_quark ()
</programlisting>
<para>Error domain for markup parsing.
Errors in this domain will be from the <link linkend="GMarkupError"><type>GMarkupError</type></link> enumeration.
See <link linkend="GError"><type>GError</type></link> for information on error domains.</para>
</refsect2>
<refsect2 id="GMarkupParseFlags" role="enum">
<title>enum GMarkupParseFlags</title>
<indexterm zone="GMarkupParseFlags"><primary sortas="MarkupParseFlags">GMarkupParseFlags</primary></indexterm>
<para>Flags that affect the behaviour of the parser.</para>
<refsect3 id="GMarkupParseFlags.members" role="enum_members">
<title>Members</title>
<informaltable role="enum_members_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="enum_members_name" colwidth="300px"/>
<colspec colname="enum_members_description"/>
<colspec colname="enum_members_annotations" colwidth="200px"/>
<tbody>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-DO-NOT-USE-THIS-UNSUPPORTED-FLAG:CAPS">G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG</para></entry>
<entry role="enum_member_description"><para>flag you should not use</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-TREAT-CDATA-AS-TEXT:CAPS">G_MARKUP_TREAT_CDATA_AS_TEXT</para></entry>
<entry role="enum_member_description"><para>When this flag is set, CDATA marked
sections are not passed literally to the <parameter>passthrough</parameter>
 function of
the parser. Instead, the content of the section (without the
<literal>&lt;![CDATA[</literal> and <literal>]]&amp;gt;</literal>) is
passed to the <parameter>text</parameter>
 function. This flag was added in GLib 2.12</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-PREFIX-ERROR-POSITION:CAPS">G_MARKUP_PREFIX_ERROR_POSITION</para></entry>
<entry role="enum_member_description"><para>Normally errors caught by GMarkup
itself have line/column information prefixed to them to let the
caller know the location of the error. When this flag is set the
location information is also prefixed to errors generated by the
<link linkend="GMarkupParser"><type>GMarkupParser</type></link> implementation functions</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-IGNORE-QUALIFIED:CAPS">G_MARKUP_IGNORE_QUALIFIED</para></entry>
<entry role="enum_member_description"><para>Ignore (don't report) qualified
attributes and tags, along with their contents.  A qualified
attribute or tag is one that contains ':' in its name (ie: is in
another namespace).  Since: 2.40.</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="GMarkupParseContext" role="struct">
<title>GMarkupParseContext</title>
<indexterm zone="GMarkupParseContext"><primary sortas="MarkupParseContext">GMarkupParseContext</primary></indexterm>
<programlisting language="C">typedef struct _GMarkupParseContext GMarkupParseContext;</programlisting>
<para>A parse context is used to parse a stream of bytes that
you expect to contain marked-up text.</para>
<para>See <link linkend="g-markup-parse-context-new"><function>g_markup_parse_context_new()</function></link>, <link linkend="GMarkupParser"><type>GMarkupParser</type></link>, and so
on for more details.</para>
</refsect2>
<refsect2 id="GMarkupParser" role="struct">
<title>struct GMarkupParser</title>
<indexterm zone="GMarkupParser"><primary sortas="MarkupParser">GMarkupParser</primary></indexterm>
<programlisting language="C">struct GMarkupParser {
  /* Called for open tags &lt;foo bar="baz"&gt; */
  void (*start_element)  (GMarkupParseContext *context,
                          const gchar         *element_name,
                          const gchar        **attribute_names,
                          const gchar        **attribute_values,
                          gpointer             user_data,
                          GError             **error);

  /* Called for close tags &lt;/foo&gt; */
  void (*end_element)    (GMarkupParseContext *context,
                          const gchar         *element_name,
                          gpointer             user_data,
                          GError             **error);

  /* Called for character data */
  /* text is not nul-terminated */
  void (*text)           (GMarkupParseContext *context,
                          const gchar         *text,
                          gsize                text_len,
                          gpointer             user_data,
                          GError             **error);

  /* Called for strings that should be re-saved verbatim in this same
   * position, but are not otherwise interpretable.  At the moment
   * this includes comments and processing instructions.
   */
  /* text is not nul-terminated. */
  void (*passthrough)    (GMarkupParseContext *context,
                          const gchar         *passthrough_text,
                          gsize                text_len,
                          gpointer             user_data,
                          GError             **error);

  /* Called on error, including one set by other
   * methods in the vtable. The GError should not be freed.
   */
  void (*error)          (GMarkupParseContext *context,
                          GError              *error,
                          gpointer             user_data);
};
</programlisting>
<para>Any of the fields in <link linkend="GMarkupParser"><type>GMarkupParser</type></link> can be <link linkend="NULL:CAPS"><literal>NULL</literal></link>, in which case they
will be ignored. Except for the <parameter>error</parameter>
 function, any of these callbacks
can set an error; in particular the <link linkend="G-MARKUP-ERROR-UNKNOWN-ELEMENT:CAPS"><literal>G_MARKUP_ERROR_UNKNOWN_ELEMENT</literal></link>,
<link linkend="G-MARKUP-ERROR-UNKNOWN-ATTRIBUTE:CAPS"><literal>G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE</literal></link>, and <link linkend="G-MARKUP-ERROR-INVALID-CONTENT:CAPS"><literal>G_MARKUP_ERROR_INVALID_CONTENT</literal></link>
errors are intended to be set from these callbacks. If you set an error
from a callback, <link linkend="g-markup-parse-context-parse"><function>g_markup_parse_context_parse()</function></link> will report that error
back to its caller.</para>
<refsect3 id="GMarkupParser.members" role="struct_members">
<title>Members</title>
<informaltable role="struct_members_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="struct_members_name" colwidth="300px"/>
<colspec colname="struct_members_description"/>
<colspec colname="struct_members_annotations" colwidth="200px"/>
<tbody>
<row role="member"><entry role="struct_member_name"><para><structfield id="GMarkupParser.start-element">start_element</structfield>&#160;()</para></entry>
<entry role="struct_member_description"><para>Callback to invoke when the opening tag of an element
is seen. The callback's <parameter>attribute_names</parameter>
and <parameter>attribute_values</parameter>
parameters
are <link linkend="NULL:CAPS"><literal>NULL</literal></link>-terminated.</para></entry>
<entry role="struct_member_annotations"></entry>
</row>
<row role="member"><entry role="struct_member_name"><para><structfield id="GMarkupParser.end-element">end_element</structfield>&#160;()</para></entry>
<entry role="struct_member_description"><para>Callback to invoke when the closing tag of an element
is seen. Note that this is also called for empty tags like
<literal>&lt;empty/&gt;</literal>.</para></entry>
<entry role="struct_member_annotations"></entry>
</row>
<row role="member"><entry role="struct_member_name"><para><structfield id="GMarkupParser.text">text</structfield>&#160;()</para></entry>
<entry role="struct_member_description"><para>Callback to invoke when some text is seen (text is always
inside an element). Note that the text of an element may be spread
over multiple calls of this function. If the
<link linkend="G-MARKUP-TREAT-CDATA-AS-TEXT:CAPS"><literal>G_MARKUP_TREAT_CDATA_AS_TEXT</literal></link> flag is set, this function is also
called for the content of CDATA marked sections.</para></entry>
<entry role="struct_member_annotations"></entry>
</row>
<row role="member"><entry role="struct_member_name"><para><structfield id="GMarkupParser.passthrough">passthrough</structfield>&#160;()</para></entry>
<entry role="struct_member_description"><para>Callback to invoke for comments, processing instructions
and doctype declarations; if you're re-writing the parsed document,
write the passthrough text back out in the same position. If the
<link linkend="G-MARKUP-TREAT-CDATA-AS-TEXT:CAPS"><literal>G_MARKUP_TREAT_CDATA_AS_TEXT</literal></link> flag is not set, this function is also
called for CDATA marked sections.</para></entry>
<entry role="struct_member_annotations"></entry>
</row>
<row role="member"><entry role="struct_member_name"><para><structfield id="GMarkupParser.error">error</structfield>&#160;()</para></entry>
<entry role="struct_member_description"><para>Callback to invoke when an error occurs.</para></entry>
<entry role="struct_member_annotations"></entry>
</row>
</tbody></tgroup></informaltable>
</refsect3>
</refsect2>
<refsect2 id="GMarkupCollectType" role="enum">
<title>enum GMarkupCollectType</title>
<indexterm zone="GMarkupCollectType"><primary sortas="MarkupCollectType">GMarkupCollectType</primary></indexterm>
<para>A mixed enumerated type and flags field. You must specify one type
(string, strdup, boolean, tristate).  Additionally, you may  optionally
bitwise OR the type with the flag <link linkend="G-MARKUP-COLLECT-OPTIONAL:CAPS"><literal>G_MARKUP_COLLECT_OPTIONAL</literal></link>.</para>
<para>It is likely that this enum will be extended in the future to
support other types.</para>
<refsect3 id="GMarkupCollectType.members" role="enum_members">
<title>Members</title>
<informaltable role="enum_members_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="enum_members_name" colwidth="300px"/>
<colspec colname="enum_members_description"/>
<colspec colname="enum_members_annotations" colwidth="200px"/>
<tbody>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-COLLECT-INVALID:CAPS">G_MARKUP_COLLECT_INVALID</para></entry>
<entry role="enum_member_description"><para>used to terminate the list of attributes
to collect</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-COLLECT-STRING:CAPS">G_MARKUP_COLLECT_STRING</para></entry>
<entry role="enum_member_description"><para>collect the string pointer directly from
the attribute_values[] array. Expects a parameter of type (const
char **). If <link linkend="G-MARKUP-COLLECT-OPTIONAL:CAPS"><literal>G_MARKUP_COLLECT_OPTIONAL</literal></link> is specified and the
attribute isn't present then the pointer will be set to <link linkend="NULL:CAPS"><literal>NULL</literal></link></para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-COLLECT-STRDUP:CAPS">G_MARKUP_COLLECT_STRDUP</para></entry>
<entry role="enum_member_description"><para>as with <link linkend="G-MARKUP-COLLECT-STRING:CAPS"><literal>G_MARKUP_COLLECT_STRING</literal></link>, but
expects a parameter of type (char **) and <link linkend="g-strdup"><function>g_strdup()</function></link>s the
returned pointer. The pointer must be freed with <link linkend="g-free"><function>g_free()</function></link></para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-COLLECT-BOOLEAN:CAPS">G_MARKUP_COLLECT_BOOLEAN</para></entry>
<entry role="enum_member_description"><para>expects a parameter of type (gboolean *)
and parses the attribute value as a boolean. Sets <link linkend="FALSE:CAPS"><literal>FALSE</literal></link> if the
attribute isn't present. Valid boolean values consist of
(case-insensitive) "false", "f", "no", "n", "0" and "true", "t",
"yes", "y", "1"</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-COLLECT-TRISTATE:CAPS">G_MARKUP_COLLECT_TRISTATE</para></entry>
<entry role="enum_member_description"><para>as with <link linkend="G-MARKUP-COLLECT-BOOLEAN:CAPS"><literal>G_MARKUP_COLLECT_BOOLEAN</literal></link>, but
in the case of a missing attribute a value is set that compares
equal to neither <link linkend="FALSE:CAPS"><literal>FALSE</literal></link> nor <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> G_MARKUP_COLLECT_OPTIONAL is
implied</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="G-MARKUP-COLLECT-OPTIONAL:CAPS">G_MARKUP_COLLECT_OPTIONAL</para></entry>
<entry role="enum_member_description"><para>can be bitwise ORed with the other fields.
If present, allows the attribute not to appear. A default value
is set depending on what value type is used</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>

</refsect1>
<refsect1 id="glib-Simple-XML-Subset-Parser.see-also">
<title>See Also</title>
<para><ulink url="http://www.w3.org/TR/REC-xml/">XML Specification</ulink></para>

</refsect1>

</refentry>
