⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glib-simple-xml-subset-parser.html

📁 glid编写实例
💻 HTML
📖 第 1 页 / 共 3 页
字号:
A parse context is used to parse a stream of bytes that you expect tocontain marked-up text. See <a href="glib-Simple-XML-Subset-Parser.html#g-markup-parse-context-new"><code class="function">g_markup_parse_context_new()</code></a>,<a href="glib-Simple-XML-Subset-Parser.html#GMarkupParser"><span class="type">GMarkupParser</span></a>, and so on for more details.</p></div><hr><div class="refsect2" lang="en"><a name="id3075927"></a><h3><a name="GMarkupParser"></a>GMarkupParser</h3><a class="indexterm" name="id3075937"></a><pre class="programlisting">typedef struct {  /* 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);} GMarkupParser;</pre><p>Any of the fields in <a href="glib-Simple-XML-Subset-Parser.html#GMarkupParser"><span class="type">GMarkupParser</span></a> can be <code class="literal">NULL</code>, in which case theywill be ignored. Except for the <em class="parameter"><code>error</code></em> function, any of thesecallbacks can set an error; in particular the<code class="literal">G_MARKUP_ERROR_UNKNOWN_ELEMENT</code>, <code class="literal">G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE</code>,and <code class="literal">G_MARKUP_ERROR_INVALID_CONTENT</code> errors are intended to be set from these callbacks. If you set an error from a callback,<a href="glib-Simple-XML-Subset-Parser.html#g-markup-parse-context-parse"><code class="function">g_markup_parse_context_parse()</code></a> will report that error back to its caller.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="structfield"><code>start_element</code></em>&#160;()</span></td><td>Callback to invoke when the opening tag of an elementis seen.</td></tr><tr><td><span class="term"><em class="structfield"><code>end_element</code></em>&#160;()</span></td><td>Callback to invoke when the closing tag of an element is seen</td></tr><tr><td><span class="term"><em class="structfield"><code>text</code></em>&#160;()</span></td><td>Callback to invoke when some text is seen (text is alwaysinside an element)</td></tr><tr><td><span class="term"><em class="structfield"><code>passthrough</code></em>&#160;()</span></td><td>Callback to invoke for comments, processinginstructions and doctype declarations; if you're re-writing the parsed document, write thepassthrough text back out in the same position</td></tr><tr><td><span class="term"><em class="structfield"><code>error</code></em>&#160;()</span></td><td>Callback to invoke when an error occurs</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3076166"></a><h3><a name="g-markup-escape-text"></a>g_markup_escape_text ()</h3><a class="indexterm" name="id3076177"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gchar">gchar</a>*      g_markup_escape_text            (const <a href="glib-Basic-Types.html#gchar">gchar</a> *text,                                             <a href="glib-Basic-Types.html#gssize">gssize</a> length);</pre><p>Escapes text so that the markup parser will parse it verbatim.Less than, greater than, ampersand, etc. are replaced with thecorresponding entities. This function would typically be usedwhen writing out a file to be parsed with the markup parser.</p><p>Note that this function doesn't protect whitespace and line endingsfrom being processed according to the XML rules for normalizationof line endings and attribute values.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>text</code></em>&#160;:</span></td><td> some valid UTF-8 text</td></tr><tr><td><span class="term"><em class="parameter"><code>length</code></em>&#160;:</span></td><td> length of <em class="parameter"><code>text</code></em> in bytes</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td><td> escaped text</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3076275"></a><h3><a name="g-markup-printf-escaped"></a>g_markup_printf_escaped ()</h3><a class="indexterm" name="id3076286"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gchar">gchar</a>*      g_markup_printf_escaped         (const char *format,                                             ...);</pre><p>Formats arguments according to <em class="parameter"><code>format</code></em>, escapingall string and character arguments in the fashionof <a href="glib-Simple-XML-Subset-Parser.html#g-markup-escape-text"><code class="function">g_markup_escape_text()</code></a>. This is useful when youwant to insert literal strings into XML-style markupoutput, without having to worry that the stringsmight themselves contain markup.</p><p></p><div class="informalexample"><pre class="programlisting">const char *store = "Fortnum &amp; Mason";const char *item = "Tea";char *output;&#160;output = g_markup_printf_escaped ("&lt;purchase&gt;"                                  "&lt;store&gt;%s&lt;/store&gt;"                                  "&lt;item&gt;%s&lt;/item&gt;"                                  "&lt;/purchase&gt;",                                  store, item);</pre></div><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>format</code></em>&#160;:</span></td><td> <code class="function">printf()</code> style format string</td></tr><tr><td><span class="term"><em class="parameter"><code>...</code></em>&#160;:</span></td><td> the arguments to insert in the format string</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td><td> newly allocated result from formatting operation. Free with <a href="glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a>.</td></tr></tbody></table></div><p>Since  2.4</p></div><hr><div class="refsect2" lang="en"><a name="id3076425"></a><h3><a name="g-markup-vprintf-escaped"></a>g_markup_vprintf_escaped ()</h3><a class="indexterm" name="id3076436"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gchar">gchar</a>*      g_markup_vprintf_escaped        (const char *format,                                             va_list args);</pre><p>Formats the data in <em class="parameter"><code>args</code></em> according to <em class="parameter"><code>format</code></em>, escapingall string and character arguments in the fashionof <a href="glib-Simple-XML-Subset-Parser.html#g-markup-escape-text"><code class="function">g_markup_escape_text()</code></a>. See <a href="glib-Simple-XML-Subset-Parser.html#g-markup-printf-escaped"><code class="function">g_markup_printf_escaped()</code></a>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>format</code></em>&#160;:</span></td><td> <code class="function">printf()</code> style format string</td></tr><tr><td><span class="term"><em class="parameter"><code>args</code></em>&#160;:</span></td><td> variable argument list, similar to <code class="function">vprintf()</code></td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td><td> newly allocated result from formatting operation. Free with <a href="glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a>.</td></tr></tbody></table></div><p>Since  2.4</p></div><hr><div class="refsect2" lang="en"><a name="id3076589"></a><h3><a name="g-markup-parse-context-end-parse"></a>g_markup_parse_context_end_parse ()</h3><a class="indexterm" name="id3076600"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a>    g_markup_parse_context_end_parse                                            (<a href="glib-Simple-XML-Subset-Parser.html#GMarkupParseContext">GMarkupParseContext</a> *context,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -