glibmm 2.4: Simple XML Subset Parser

Main Page Widgets glibmm Namespaces Book

# Simple XML Subset Parser

The Glib::Markup parser is intended to parse a simple markup format that's a subset of XML. More...

## Classes
class | Glib::MarkupError
| Exception class for markup parsing errors. More...
class | Glib::Markup::AttributeKeyLess
| Binary predicate used by Markup::Parser::AttributeMap. More...
class | Glib::Markup::Parser
| The abstract markup parser base class. More...
class | Glib::Markup::ParseContext
| A parse context is used to parse marked-up documents. More...
## Typedefs
typedef Glib::MarkupError | Glib::Markup::Error
## Functions
Glib::ustring | Glib::Markup::escape_text (const Glib::ustring& text)
| Escapes text so that the markup parser will parse it verbatim.

## Detailed Description

The Glib::Markup 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. 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 Glib::Markup parser, so you can easily migrate to full-scale XML at a later time if the need arises.

Glib::Markup is not guaranteed to signal an error on all invalid XML; the parser may accept documents that an XML parser would not. However, invalid XML documents are not considered valid Glib::Markup documents.

Simplifications to XML include:

- Only UTF-8 encoding is allowed.
- No user-defined entities.
- Processing instructions, comments and the doctype declaration are "passed through" but are not interpreted in any way.
- No DTD or validation.

The markup format does support:

- Elements
- Attributes
- 5 standard entities: `&amp; &lt; &gt; &quot; &apos;`
- Character references
- Sections marked as `CDATA`

## Typedef Documentation

typedef Glib::MarkupError Glib::Markup::Error

## Function Documentation

Glib::ustring Glib::Markup::escape_text | ( | const Glib::ustring& | text | ) |

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.

Parameters:

  | text | Some valid UTF-8 text.

Returns:
  Escaped text.