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

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

📁 glid编写实例
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<html xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>Simple XML Subset Parser</title><meta name="generator" content="DocBook XSL Stylesheets V1.69.0"><link rel="start" href="index.html" title="GLib Reference Manual"><link rel="up" href="glib-utilities.html" title="GLib Utilities"><link rel="prev" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching"><link rel="next" href="glib-Key-value-file-parser.html" title="Key-value file parser"><meta name="generator" content="GTK-Doc V1.4 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="chapter" href="glib.html" title="GLib Overview"><link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals"><link rel="chapter" href="glib-core.html" title="GLib Core Application Support"><link rel="chapter" href="glib-utilities.html" title="GLib Utilities"><link rel="chapter" href="glib-data-types.html" title="GLib Data Types"><link rel="chapter" href="tools.html" title="GLib Tools"><link rel="index" href="ix01.html" title="Index"><link rel="index" href="ix02.html" title="Index of deprecated symbols"><link rel="index" href="ix03.html" title="Index of new symbols in 2.2"><link rel="index" href="ix04.html" title="Index of new symbols in 2.4"><link rel="index" href="ix05.html" title="Index of new symbols in 2.6"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="glib-Glob-style-pattern-matching.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="glib-utilities.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GLib Reference Manual</th><td><a accesskey="n" href="glib-Key-value-file-parser.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="refentry" lang="en"><a name="glib-Simple-XML-Subset-Parser"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><span class="refentrytitle">Simple XML Subset Parser</span></h2><p>Simple XML Subset Parser &#8212; parses a subset of XML.</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">#include &lt;glib.h&gt;enum        <a href="glib-Simple-XML-Subset-Parser.html#GMarkupError">GMarkupError</a>;#define     <a href="glib-Simple-XML-Subset-Parser.html#G-MARKUP-ERROR:CAPS">G_MARKUP_ERROR</a>enum        <a href="glib-Simple-XML-Subset-Parser.html#GMarkupParseFlags">GMarkupParseFlags</a>;            <a href="glib-Simple-XML-Subset-Parser.html#GMarkupParseContext">GMarkupParseContext</a>;            <a href="glib-Simple-XML-Subset-Parser.html#GMarkupParser">GMarkupParser</a>;<a href="glib-Basic-Types.html#gchar">gchar</a>*      <a href="glib-Simple-XML-Subset-Parser.html#g-markup-escape-text">g_markup_escape_text</a>            (const <a href="glib-Basic-Types.html#gchar">gchar</a> *text,                                             <a href="glib-Basic-Types.html#gssize">gssize</a> length);<a href="glib-Basic-Types.html#gchar">gchar</a>*      <a href="glib-Simple-XML-Subset-Parser.html#g-markup-printf-escaped">g_markup_printf_escaped</a>         (const char *format,                                             ...);<a href="glib-Basic-Types.html#gchar">gchar</a>*      <a href="glib-Simple-XML-Subset-Parser.html#g-markup-vprintf-escaped">g_markup_vprintf_escaped</a>        (const char *format,                                             va_list args);<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Simple-XML-Subset-Parser.html#g-markup-parse-context-end-parse">g_markup_parse_context_end_parse</a>                                            (<a href="glib-Simple-XML-Subset-Parser.html#GMarkupParseContext">GMarkupParseContext</a> *context,                                             <a href="glib-Error-Reporting.html#GError">GError</a> **error);void        <a href="glib-Simple-XML-Subset-Parser.html#g-markup-parse-context-free">g_markup_parse_context_free</a>     (<a href="glib-Simple-XML-Subset-Parser.html#GMarkupParseContext">GMarkupParseContext</a> *context);void        <a href="glib-Simple-XML-Subset-Parser.html#g-markup-parse-context-get-position">g_markup_parse_context_get_position</a>                                            (<a href="glib-Simple-XML-Subset-Parser.html#GMarkupParseContext">GMarkupParseContext</a> *context,                                             <a href="glib-Basic-Types.html#gint">gint</a> *line_number,                                             <a href="glib-Basic-Types.html#gint">gint</a> *char_number);const <a href="glib-Basic-Types.html#gchar">gchar</a>* <a href="glib-Simple-XML-Subset-Parser.html#g-markup-parse-context-get-element">g_markup_parse_context_get_element</a>                                            (<a href="glib-Simple-XML-Subset-Parser.html#GMarkupParseContext">GMarkupParseContext</a> *context);<a href="glib-Simple-XML-Subset-Parser.html#GMarkupParseContext">GMarkupParseContext</a>* <a href="glib-Simple-XML-Subset-Parser.html#g-markup-parse-context-new">g_markup_parse_context_new</a>                                            (const <a href="glib-Simple-XML-Subset-Parser.html#GMarkupParser">GMarkupParser</a> *parser,                                             <a href="glib-Simple-XML-Subset-Parser.html#GMarkupParseFlags">GMarkupParseFlags</a> flags,                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data,                                             <a href="glib-Datasets.html#GDestroyNotify">GDestroyNotify</a> user_data_dnotify);<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Simple-XML-Subset-Parser.html#g-markup-parse-context-parse">g_markup_parse_context_parse</a>    (<a href="glib-Simple-XML-Subset-Parser.html#GMarkupParseContext">GMarkupParseContext</a> *context,                                             const <a href="glib-Basic-Types.html#gchar">gchar</a> *text,                                             <a href="glib-Basic-Types.html#gssize">gssize</a> text_len,                                             <a href="glib-Error-Reporting.html#GError">GError</a> **error);</pre></div><div class="refsect1" lang="en"><a name="id3075498"></a><h2>Description</h2><p>The "GMarkup" parser is intended to parse a simple markup formatthat's a subset of XML. This is a small, efficient, easy-to-useparser. It should not be used if you expect to interoperate with other applications generating full-scale XML. However, it's very useful forapplication data files, config files, etc. where you know yourapplication will be the only one writing the file. Full-scale XMLparsers should be able to parse the subset used by GMarkup, so you caneasily migrate to full-scale XML at a later time if the need arises.</p><p>GMarkup is not guaranteed to signal an error on all invalid XML; theparser may accept documents that an XML parser would not. However, XML documents which are not well-formed<sup>[<a name="wellformed" href="#ftn.wellformed">2</a>]</sup> are not considered valid GMarkup documents. </p><p>Simplifications to XML include:</p><div class="itemizedlist"><ul type="disc"><li><p>Only UTF-8 encoding is allowed.</p></li><li><p>No user-defined entities.</p></li><li><p>Processing instructions, comments and the doctype declaration are "passed through" but are not interpreted in any way.</p></li><li><p>No DTD or validation.</p></li></ul></div><p></p><p>The markup format does support:</p><div class="itemizedlist"><ul type="disc"><li><p>Elements</p></li><li><p>Attributes</p></li><li><p>5 standard entities: <code class="literal">&amp;amp; &amp;lt; &amp;gt; &amp;quot; &amp;apos;</code></p></li><li><p>Character references</p></li><li><p>Sections marked as CDATA</p></li></ul></div><p></p></div><div class="refsect1" lang="en"><a name="id3075623"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3075629"></a><h3><a name="GMarkupError"></a>enum GMarkupError</h3><a class="indexterm" name="id3075640"></a><pre class="programlisting">typedef enum{  G_MARKUP_ERROR_BAD_UTF8,  G_MARKUP_ERROR_EMPTY,  G_MARKUP_ERROR_PARSE,  /* These three are primarily intended for specific GMarkupParser   * implementations to set.   */  G_MARKUP_ERROR_UNKNOWN_ELEMENT,  G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,  G_MARKUP_ERROR_INVALID_CONTENT} GMarkupError;</pre><p>Error codes returned by markup parsing.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><code class="literal">G_MARKUP_ERROR_BAD_UTF8</code></span></td><td>text being parsed was not valid UTF-8</td></tr><tr><td><span class="term"><code class="literal">G_MARKUP_ERROR_EMPTY</code></span></td><td>document contained nothing, or only whitespace</td></tr><tr><td><span class="term"><code class="literal">G_MARKUP_ERROR_PARSE</code></span></td><td>document was ill-formed</td></tr><tr><td><span class="term"><code class="literal">G_MARKUP_ERROR_UNKNOWN_ELEMENT</code></span></td><td>error should be set by <a href="glib-Simple-XML-Subset-Parser.html#GMarkupParser"><span class="type">GMarkupParser</span></a> functions; element wasn't known</td></tr><tr><td><span class="term"><code class="literal">G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE</code></span></td><td>error should be set by <a href="glib-Simple-XML-Subset-Parser.html#GMarkupParser"><span class="type">GMarkupParser</span></a> functions; attribute wasn't known</td></tr><tr><td><span class="term"><code class="literal">G_MARKUP_ERROR_INVALID_CONTENT</code></span></td><td>error should be set by <a href="glib-Simple-XML-Subset-Parser.html#GMarkupParser"><span class="type">GMarkupParser</span></a> functions; something was wrong with contents of the document, e.g. invalid attribute value</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3075784"></a><h3><a name="G-MARKUP-ERROR:CAPS"></a>G_MARKUP_ERROR</h3><a class="indexterm" name="id3075794"></a><pre class="programlisting">#define G_MARKUP_ERROR g_markup_error_quark ()</pre><p>Error domain for markup parsing. Errors in this domain willbe from the <a href="glib-Simple-XML-Subset-Parser.html#GMarkupError"><span class="type">GMarkupError</span></a> enumeration. See <a href="glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for information on error domains.</p></div><hr><div class="refsect2" lang="en"><a name="id3075828"></a><h3><a name="GMarkupParseFlags"></a>enum GMarkupParseFlags</h3><a class="indexterm" name="id3075840"></a><pre class="programlisting">typedef enum{  /* Hmm, can't think of any at the moment */  G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 &lt;&lt; 0  } GMarkupParseFlags;</pre><p>There are no flags right now. Pass "0" for the flags argument to all functions.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><code class="literal">G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG</code></span></td><td>flag you should not use.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3075879"></a><h3><a name="GMarkupParseContext"></a>GMarkupParseContext</h3><a class="indexterm" name="id3075890"></a><pre class="programlisting">typedef struct _GMarkupParseContext GMarkupParseContext;</pre><p>

⌨️ 快捷键说明

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