1xmlparsing(3) Coin xmlparsing(3)
2
3
4
6 xmlparsing - XML Parsing with Coin For Coin 3.0, we added an XML parser
7 to Coin. This document describes how it can be used for generic
8 purposes.
9
10 Why another XML parser, you might ask? First of all, the XML parser is
11 actually a third-party parser, expat. Coin needed one, and many Coin-
12 dependent projects needed one as well. We therefore needed to expose an
13 API for it. However, integrating a 3rd-party parser into Coin, we can
14 not expose its API directly, or other projects also using Expat would
15 get conflicts. We therefore needed to expose the XML API with a unique
16 API, hence the API you see here. It is based on a XML DOM API we use(d)
17 in a couple of other projects, but it has been tweaked to fit into Coin
18 and to be wrapped over Expat (the original implementation just used
19 flex).
20
21 The XML parser is both a streaming parser and a DOM parser. Being a
22 streaming parser means that documents can be read in without having to
23 be fully contained in memory. When used as a DOM parser, the whole
24 document is fully parsed in first, and then inspected by client code by
25 traversing the DOM. The two modes can actually be mixed arbitrarily if
26 ending up with a partial DOM sounds useful.
27
28 The XML parser has both a C API and a C++ API. The C++ API is just a
29 wrapper around the C API, and only serves as convenience if you prefer
30 to read/write C++ code (which is tighter) over more verbose C code.
31
32 The C API naming convention may look a bit strange, unless you have
33 written libraries to be wrapped for scheme/lisp-like languages before.
34 Then you might be familiar with the convention of suffixing your
35 functions based on their behaviour/usage meaning. Mutating functions
36 are suffixed with '!', or '_x' for (eXclamation point), and predicates
37 are suffixed with '?', or '_p' in C.
38
39 The simplest way to use the XML parser is to just call
40 cc_xml_read_file(filename) and then traverse the DOM model through
41 using cc_xml_doc_get_root(), cc_xml_elt_get_child(), and
42 cc_xml_elt_get_attr().
43
44 See also
45 XML related functions and objects, cc_xml_doc, cc_xml_elt,
46 cc_xml_attr
47
48Version 4.0.0 Wed Jul 21 2021 xmlparsing(3)