Update README and CHANGES to markdown.

This commit is contained in:
Michael Sweet 2017-03-22 15:23:27 -04:00
parent 89a9742c0e
commit 39065168d4
4 changed files with 394 additions and 572 deletions

376
CHANGES
View File

@ -1,376 +0,0 @@
CHANGES - 2016-06-12
--------------------
CHANGES IN Mini-XML 2.10
- The version number in mxml.h was wrong (Bug #532)
- The mxml.spec file was out of date (Bug #521)
- Mini-XML no longer allows malformed element names (Bug #509)
- mxmlLoad* and mxmlSAXLoad* did not properly create text nodes when
MXML_TEXT_CALLBACK was specified (Bug #531)
- mxmlDelete used a recursive algorithm which could require large
amounts of stack space depending on the file (Bug #549, CVE-2016-4570)
- mxmlWrite* used a recursive algorithm which could require large
amounts of stack space depending on the file (Bug #549, CVE-2016-4571)
CHANGES IN Mini-XML 2.9
- mxmlLoad* did not correctly load value nodes with MXML_NO_CALLBACK
or MXML_TEXT_CALLBACK (Bug #502)
CHANGES IN Mini-XML 2.8
- Now call docsetutil using xcrun on OS X (Bug #458)
- mxmldoc did not escape special HTML characters inside @code foo@
comments.
- Fixed a memory leak in mxmlElementDeleteAttr (Bug #452)
- Added MXML_MAJOR/MINOR_VERSION definitions to mxml.h (Bug $461)
- Fixed a bug reading UTF-16 characters from a file (Bug #454)
- Fixed a memory leak when loading invalid XML (Bug #496)
- Fixed an XML fragment loading problem (Bug #494)
CHANGES IN Mini-XML 2.7
- Added 64-bit configurations to the VC++ project files (STR #129)
- Fixed conformance of mxmldoc's HTML and CSS output.
- Added data accessor ("get") functions and made the mxml_node_t and
mxml_index_t structures private but still available in the Mini-XML
header to preserve source compatibility (STR #118)
- Updated the source headers to reference the Mini-XML license and its
exceptions to the LGPL2 (STR #108)
- Fixed a memory leak when loading a badly-formed XML file (STR #121)
- Added a new mxmlFindPath() function to find the value node of a
named element (STR #110)
- Building a static version of the library did not work on Windows
(STR #112)
- The shared library did not include a destructor for the thread-
specific data key on UNIX-based operating systems (STR #103)
- mxmlLoad* did not error out on XML with multiple root nodes (STR #101)
- Fixed an issue with the _mxml_vstrdupf function (STR #107)
- mxmlSave* no longer write all siblings of the passed node, just that
node and its children (STR #109)
CHANGES IN Mini-XML 2.6
- Documentation fixes (STR #91, STR #92)
- The mxmldoc program did not handle typedef comments properly (STR #72)
- Added support for "long long" printf formats.
- The XML parser now ignores BOMs in UTF-8 XML files (STR #89)
- The mxmldoc program now supports generating Xcode documentation sets.
- mxmlSave*() did not output UTF-8 correctly on some platforms.
- mxmlNewXML() now adds encoding="utf-8" in the ?xml directive to avoid
problems with non-conformant XML parsers that assume something other
than UTF-8 as the default encoding.
- Wrapping was not disabled when mxmlSetWrapMargin(0) was called, and
"<?xml ... ?>" was always followed by a newline (STR #76)
- The mxml.pc.in file was broken (STR #79)
- The mxmldoc program now handles "typedef enum name {} name" correctly
(STR #72)
CHANGES IN Mini-XML 2.5
- The mxmldoc program now makes greater use of CSS and
supports a --css option to embed an alternate stylesheet.
- The mxmldoc program now supports --header and --footer
options to insert documentation content before and
after the generated content.
- The mxmldoc program now supports a --framed option to
generate framed HTML output.
- The mxmldoc program now creates a table of contents
including any headings in the --intro file when
generating HTML output.
- The man pages and man page output from mxmldoc did
not use "\-" for dashes (STR #68)
- The debug version of the Mini-XML DLL could not be
built (STR #65)
- Processing instructions and directives did not work
when not at the top level of a document (STR #67)
- Spaces around the "=" in attributes were not supported
(STR #67)
CHANGES IN Mini-XML 2.4
- Fixed shared library build problems on HP-UX and Mac OS X.
- The mxmldoc program did not output argument descriptions
for functions properly.
- All global settings (custom, error, and entity callbacks
and the wrap margin) are now managed separately for each
thread.
- Added mxmlElementDeleteAttr() function (STR #59)
- mxmlElementSetAttrf() did not work (STR #57)
- mxmlLoad*() incorrectly treated declarations as parent
elements (STR #56)
- mxmlLoad*() incorrectly allowed attributes without values
(STR #47)
- Fixed Visual C++ build problems (STR #49)
- mxmlLoad*() did not return NULL when an element contained
an error (STR #46)
- Added support for the apos character entity (STR #54)
- Fixed whitespace detection with Unicode characters (STR
#48)
- mxmlWalkNext() and mxmlWalkPrev() did not work correctly
when called with a node with no children as the top node
(STR #53)
CHANGES IN Mini-XML 2.3
- Added two exceptions to the LGPL to support static
linking of applications against Mini-XML
- The mxmldoc utility can now generate man pages, too.
- Added a mxmlNewXML() function
- Added a mxmlElementSetAttrf() function (STR #43)
- Added snprintf() emulation function for test program (STR
#32)
- Added the _CRT_SECURE_NO_DEPRECATE definition when
building on VC++ 2005 (STR #36)
- mxmlLoad*() did not detect missing > characters in
elements (STR #41)
- mxmlLoad*() did not detect missing close tags at the end
of an XML document (STR #45)
- Added user_data and ref_count members to mxml_node_t
structure
- Added mxmlReleaseNode() and mxmlRetainNode() APIs for
reference-counted nodes
- Added mxmlSetWrapMargin() to control the wrapping of XML
output
- Added conditional check for EINTR error code for
certain Windows compilers that do not define it (STR
#33)
- The mxmldoc program now generates correct HTML 4.0
output - previously it generated invalid XHTML
- The mxmldoc program now supports "@deprecated@,
"@private@", and "@since version@" comments
- Fixed function and enumeration type bugs in mxmldoc.
- Fixed the XML schema for mxmldoc
- The mxmldoc program now supports --intro, --section,
and --title options
- The mxmlLoad*() functions could leak a node on an error
(STR #27)
- The mxml_vsnprintf() function could get in an infinite
loop on a buffer overflow (STR #25)
- Added new mxmlNewCDATA() and mxmlSetCDATA() functions
to create and set CDATA nodes, which are really just
special element nodes
- Added new MXML_IGNORE type and MXML_IGNORE_CB callback
to ignore non-element nodes, e.g. whitespace
- mxmlLoad*() crashed when reporting an error in some
invalid XML (STR #23)
CHANGES IN Mini-XML 2.2.2
- mxmlLoad*() did not treat custom data as opaque, so
whitespace characters would be lost.
CHANGES IN Mini-XML 2.2.1
- mxmlLoadFd(), mxmlLoadFile(), and mxmlLoadString() now
correctly return NULL on error (STR #21)
- mxmlNewInteger(), mxmlNewOpaque(), mxmlNewReal(),
mxmlNewText(), and mxmlNewTextf() incorrectly required
a parent node (STR #22)
- Fixed an XML output bug in mxmldoc.
- The "make install" target now uses the install command
to set the proper permissions on UNIX/Linux/OSX.
- Fixed a MingW/Cygwin compilation problem (STR #18)
CHANGES IN Mini-XML 2.2
- Added shared library support (STR #17)
- mxmlLoad*() now returns an error when an XML stream
contains illegal control characters (STR #10)
- mxmlLoad*() now returns an error when an element
contains two attributes with the same name in
conformance with the XML spec (STR #16)
- Added support for CDATA (STR #14, STR #15)
- Updated comment and processing instruction handling -
no entity support per XML specification.
- Added checking for invalid comment termination ("--->"
is not allowed)
CHANGES IN Mini-XML 2.1
- Added support for custom data nodes (STR #6)
- Now treat UTF-8 sequences which are longer than
necessary as an error (STR #4)
- Fixed entity number support (STR #8)
- Fixed mxmlLoadString() bug with UTF-8 (STR #7)
- Fixed entity lookup bug (STR #5)
- Added mxmlLoadFd() and mxmlSaveFd() functions.
- Fixed multi-word UTF-16 handling.
CHANGES IN Mini-XML 2.0
- New programmers manual.
- Added Visual C++ project files for Microsoft Windows
users.
- Added optimizations to mxmldoc, mxmlSaveFile(), and
mxmlIndexNew() (STR #2)
- mxmlEntityAddCallback() now returns an integer status
(STR #2)
- Added UTF-16 support (input only; all output is UTF-8)
- Added index functions to build a searchable index of
XML nodes.
- Added character entity callback interface to support
additional character entities beyond those defined in
the XHTML specification.
- Added support for XHTML character entities.
- The mxmldoc utility now produces XML output which
conforms to an updated XML schema, described in the file
"doc/mxmldoc.xsd".
- Changed the whitespace callback interface to return
strings instead of a single character, allowing for
greater control over the formatting of XML files
written using Mini-XML. THIS CHANGE WILL REQUIRE
CHANGES TO YOUR 1.x CODE IF YOU USE WHITESPACE
CALLBACKS.
- The mxmldoc utility is now capable of documenting C++
classes, functions, and structures, and correctly
handles C++ comments.
- Added new modular tests for mxmldoc.
- Updated the mxmldoc output to be more compatible with
embedding in manuals produced with HTMLDOC.
- The makefile incorrectly included a "/" separator
between the destination path and install path. This
caused problems when building and installing with
MingW.
CHANGES IN Mini-XML 1.3
- Fixes for mxmldoc.
- Added support for reading standard HTML entity names.
- mxmlLoadString/File() did not decode character
entities in element names, attribute names, or
attribute values.
- mxmlLoadString/File() would crash when loading non-
conformant XML data under an existing parent (top)
node.
- Fixed several bugs in the mxmldoc utility.
- Added new error callback function to catch a variety
of errors and log them to someplace other than stderr.
- The mxmlElementSetAttr() function now allows for NULL
attribute values.
- The load and save functions now properly handle quoted
element and attribute name strings properly, e.g. for
!DOCTYPE declarations.
CHANGES IN Mini-XML 1.2
- Added new "set" methods to set the value of a node.
- Added new formatted text methods mxmlNewTextf() and
mxmlSetTextf() to create/set a text node value using
printf-style formats.
- Added new standard callbacks for use with the mxmlLoad
functions.
- Updated the HTML documentation to include examples of
the walk and load function output.
- Added --with/without-ansi configure option to control
the strdup() function check.
- Added --with/without-snprintf configure option to
control the snprintf() and vsnprintf() function
checks.
CHANGES IN Mini-XML 1.1.2
- The mxml(3) man page wasn't updated for the string
functions.
- mxmlSaveString() returned the wrong number of
characters.
- mxml_add_char() updated the buffer pointer in the
wrong place.
CHANGES IN Mini-XML 1.1.1
- The private mxml_add_ch() function did not update the
start-of-buffer pointer which could cause a crash when
using mxmlSaveString().
- The private mxml_write_ws() function called putc()
instead of using the proper callback which could cause
a crash when using mxmlSaveString().
- Added a mxmlSaveAllocString() convenience function for
saving an XML node tree to an allocated string.
CHANGES IN Mini-XML 1.1
- The mxmlLoadFile() function now uses dynamically
allocated string buffers for element names, attribute
names, and attribute values. Previously they were
capped at 16383, 255, and 255 bytes, respectively.
- Added a new mxmlLoadString() function for loading an
XML node tree from a string.
- Added a new mxmlSaveString() function for saving an
XML node tree to a string.
- Add emulation of strdup() if the local platform does
not provide the function.
CHANGES IN Mini-XML 1.0
- The mxmldoc program now handles function arguments,
structures, unions, enumerations, classes, and
typedefs properly.
- Documentation provided via mxmldoc and more in-line
comments in the code.
- Added man pages and packaging files.
CHANGES IN Mini-XML 0.93
- New mxmldoc example program that is also used to
create and update code documentation using XML and
produce HTML reference pages.
- Added mxmlAdd() and mxmlRemove() functions to add and
remove nodes from a tree. This provides more
flexibility over where the nodes are inserted and
allows nodes to be moved within the tree as needed.
- mxmlLoadFile() now correctly handles comments.
- mxmlLoadFile() now supports the required "gt", "quot",
and "nbsp" character entities.
- mxmlSaveFile() now uses newlines as whitespace
when valid to do so.
- mxmlFindElement() now also takes attribute name and
attribute value string arguments to limit the search
to specific elements with attributes and/or values.
NULL pointers can be used as "wildcards".
- Added uninstall target to makefile, and auto-reconfig
if Makefile.in or configure.in are changed.
- mxmlFindElement(), mxmlWalkNext(), and mxmlWalkPrev()
now all provide "descend" arguments to control whether
they descend into child nodes in the tree.
- Fixed some whitespace issues in mxmlLoadFile().
- Fixed Unicode output and whitespace issues in
mxmlSaveFile().
- mxmlSaveFile() now supports a whitespace callback to
provide more human-readable XML output under program
control.
CHANGES IN Mini-XML 0.92
- mxmlSaveFile() didn't return a value on success.
CHANGES IN Mini-XML 0.91
- mxmlWalkNext() would go into an infinite loop.
CHANGES IN Mini-XML 0.9
- Initial public release.

206
CHANGES.md Normal file
View File

@ -0,0 +1,206 @@
# Changes in Mini-XML 2.11
# Changes in Mini-XML 2.10
- The version number in mxml.h was wrong.
- The mxml.spec file was out of date.
- Mini-XML no longer allows malformed element names.
- `mxmlLoad*` and `mxmlSAXLoad*` did not properly create text nodes when
MXML_TEXT_CALLBACK was specified.
- `mxmlDelete` used a recursive algorithm which could require large amounts of
stack space depending on the file. (CVE-2016-4570)
- `mxmlWrite*` used a recursive algorithm which could require large amounts of
stack space depending on the file. (CVE-2016-4571)
# Changes in Mini-XML 2.9
- `mxmlLoad*` did not correctly load value nodes with `MXML_NO_CALLBACK` or
`MXML_TEXT_CALLBACK`.
# Changes in Mini-XML 2.8
- Now call docsetutil using xcrun on macOS.
- mxmldoc did not escape special HTML characters inside @code foo@ comments.
- Fixed a memory leak in `mxmlElementDeleteAttr`.
- Added `MXML_MAJOR/MINOR_VERSION` definitions to mxml.h.
- Fixed a bug reading UTF-16 characters from a file.
- Fixed a memory leak when loading invalid XML.
- Fixed an XML fragment loading problem.
# Changes in Mini-XML 2.7
- Added 64-bit configurations to the VC++ project files.
- Fixed conformance of mxmldoc's HTML and CSS output.
- Added data accessor ("get") functions and made the `mxml_node_t` and
`mxml_index_t` structures private but still available in the Mini-XML header to
preserve source compatibility.
- Updated the source headers to reference the Mini-XML license and its
exceptions to the LGPL2.
- Fixed a memory leak when loading a badly-formed XML file.
- Added a new mxmlFindPath function to find the value node of a named element.
- Building a static version of the library did not work on Windows.
- The shared library did not include a destructor for the thread-specific data
key on UNIX-based operating systems.
- mxmlLoad* did not error out on XML with multiple root nodes.
- Fixed an issue with the `_mxml_vstrdupf` function.
- `mxmlSave*` no longer write all siblings of the passed node, just that node
and its children.
# Changes in Mini-XML 2.6
- Documentation fixes.
- The mxmldoc program did not handle typedef comments properly.
- Added support for "long long" printf formats.
- The XML parser now ignores BOMs in UTF-8 XML files.
- The mxmldoc program now supports generating Xcode documentation sets.
- `mxmlSave*` did not output UTF-8 correctly on some platforms.
- `mxmlNewXML` now adds encoding="utf-8" in the ?xml directive to avoid
problems with non-conformant XML parsers that assume something other
than UTF-8 as the default encoding.
- Wrapping was not disabled when mxmlSetWrapMargin(0) was called, and
"<?xml ... ?>" was always followed by a newline.
- The mxml.pc.in file was broken.
- The mxmldoc program now handles "typedef enum name {} name" correctly.
# Changes in Mini-XML 2.5
- The mxmldoc program now makes greater use of CSS and supports a `--css` option
to embed an alternate stylesheet.
- The mxmldoc program now supports `--header` and `--footer` options to insert
documentation content before and after the generated content.
- The mxmldoc program now supports a `--framed` option to generate framed HTML
output.
- The mxmldoc program now creates a table of contents including any headings in
the `--intro` file when generating HTML output.
- The man pages and man page output from mxmldoc did not use "\-" for dashes.
- The debug version of the Mini-XML DLL could not be built.
- Processing instructions and directives did not work when not at the top level
of a document.
- Spaces around the "=" in attributes were not supported.
# Changes in Mini-XML 2.4
- Fixed shared library build problems on HP-UX and Mac macOS.
- The mxmldoc program did not output argument descriptions for functions
properly.
- All global settings (custom, error, and entity callbacks and the wrap margin)
are now managed separately for each thread.
- Added `mxmlElementDeleteAttr` function.
- `mxmlElementSetAttrf` did not work.
- `mxmlLoad*` incorrectly treated declarations as parent elements.
- `mxmlLoad*` incorrectly allowed attributes without values.
- Fixed Visual C++ build problems.
- `mxmlLoad*` did not return NULL when an element contained an error.
- Added support for the apos character entity.
- Fixed whitespace detection with Unicode characters.
- `mxmlWalkNext` and `mxmlWalkPrev` did not work correctly when called with a
node with no children as the top node.
# Changes in Mini-XML 2.3
- Added two exceptions to the LGPL to support static linking of applications
against Mini-XML.
- The mxmldoc utility can now generate man pages, too.
- Added a mxmlNewXML function.
- Added a mxmlElementSetAttrf function.
- Added snprintf() emulation function for test program.
- Added the _CRT_SECURE_NO_DEPRECATE definition when building on VC++ 2005.
- mxmlLoad* did not detect missing > characters in elements.
- mxmlLoad* did not detect missing close tags at the end of an XML document.
- Added user_data and ref_count members to mxml_node_t structure.
- Added mxmlReleaseNode() and mxmlRetainNode() APIs for reference-counted nodes.
- Added mxmlSetWrapMargin() to control the wrapping of XML output.
- Added conditional check for EINTR error code for certain Windows compilers
that do not define it.
- The mxmldoc program now generates correct HTML 4.0 output - previously it
generated invalid XHTML.
- The mxmldoc program now supports "@deprecated@, "@private@", and "@since
version@" comments.
- Fixed function and enumeration type bugs in mxmldoc.
- Fixed the XML schema for mxmldoc.
- The mxmldoc program now supports `--intro`, `--section`, and `--title`
options.
- The `mxmlLoad*` functions could leak a node on an error.
- The `mxml_vsnprintf` function could get in an infinite loop on a buffer
overflow.
- Added new `mxmlNewCDATA` and `mxmlSetCDATA` functions to create and set CDATA
nodes, which are really just special element nodes.
- Added new `MXML_IGNORE` type and `MXML_IGNORE_CB` callback to ignore non-
element nodes, e.g. whitespace.
- `mxmlLoad*` crashed when reporting an error in some invalid XML.
# Changes in Mini-XML 2.2.2
- `mxmlLoad*` did not treat custom data as opaque, so whitespace characters
would be lost.
# Changes in Mini-XML 2.2.1
- `mxmlLoad*` now correctly return NULL on error.
- `mxmlNewInteger`, `mxmlNewOpaque`, `mxmlNewReal`, `mxmlNewText`, and
`mxmlNewTextf` incorrectly required a parent node.
- Fixed an XML output bug in mxmldoc.
- The "make install" target now uses the install command to set the proper
permissions on UNIX/Linux/macOS.
- Fixed a MingW/Cygwin compilation problem.
# Changes in Mini-XML 2.2
- Added shared library support.
- `mxmlLoad*` now return an error when an XML stream contains illegal control
characters.
- `mxmlLoad*` now return an error when an element contains two attributes with
the same name in conformance with the XML spec.
- Added support for CDATA.
- Updated comment and processing instruction handling - no entity support per
XML specification.
- Added checking for invalid comment termination: "--->" is not allowed.
# Changes in Mini-XML 2.1
- Added support for custom data nodes.
- Now treat UTF-8 sequences which are longer than necessary as an error.
- Fixed entity number support.
- Fixed mxmlLoadString() bug with UTF-8.
- Fixed entity lookup bug.
- Added `mxmlLoadFd` and `mxmlSaveFd` functions.
- Fixed multi-word UTF-16 handling.
# Changes in Mini-XML 2.0
- New programmers manual.
- Added Visual C++ project files for Microsoft Windows users.
- Added optimizations to mxmldoc, `mxmlSaveFile`, and `mxmlIndexNew`.
- `mxmlEntityAddCallback` now returns an integer status.
- Added UTF-16 support (input only; all output is UTF-8).
- Added index functions to build a searchable index of XML nodes.
- Added character entity callback interface to support additional character
entities beyond those defined in the XHTML specification.
- Added support for XHTML character entities.
- The mxmldoc utility now produces XML output which conforms to an updated XML
schema, described in the file "doc/mxmldoc.xsd".
- Changed the whitespace callback interface to return strings instead of a
single character, allowing for greater control over the formatting of XML
files written using Mini-XML. THIS CHANGE WILL REQUIRE CHANGES TO YOUR 1.x
CODE IF YOU USE WHITESPACE CALLBACKS.
- The mxmldoc utility is now capable of documenting C++ classes, functions, and
structures, and correctly handles C++ comments.
- Added new modular tests for mxmldoc.
- Updated the mxmldoc output to be more compatible with embedding in manuals
produced with HTMLDOC.
- The makefile incorrectly included a "/" separator between the destination path
and install path. This caused problems when building and installing with
MingW.

196
README
View File

@ -1,196 +0,0 @@
README - 2016-06-12
-------------------
INTRODUCTION
This README file describes the Mini-XML library version 2.10.
Mini-XML is a small XML parsing library that you can use to read XML and
XML-like data files in your application without requiring large non-standard
libraries. Mini-XML only requires an ANSI C compatible compiler (GCC works,
as do most vendors' ANSI C compilers) and a "make" program.
Mini-XML provides the following functionality:
- Reading of UTF-8 and UTF-16 and writing of UTF-8 encoded XML files and
strings.
- Data is stored in a linked-list tree structure, preserving the XML
data hierarchy.
- Supports arbitrary element names, attributes, and attribute values
with no preset limits, just available memory.
- Supports integer, real, opaque ("cdata"), and text data types in
"leaf" nodes.
- Functions for creating and managing trees of data.
- "Find" and "walk" functions for easily locating and navigating trees
of data.
Mini-XML doesn't do validation or other types of processing on the data
based upon schema files or other sources of definition information.
BUILDING Mini-XML
Mini-XML comes with an autoconf-based configure script; just type the
following command to get things going:
./configure
The default install prefix is /usr/local, which can be overridden using the
--prefix option:
./configure --prefix=/foo
Other configure options can be found using the --help option:
./configure --help
Once you have configured the software, type "make" to do the build and run
the test program to verify that things are working, as follows:
make
If you are using Mini-XML under Microsoft Windows with Visual C++, use the
included project files in the "vcnet" subdirectory to build the library
instead. Note: The static library on Windows is NOT thread-safe.
INSTALLING Mini-XML
The "install" target will install Mini-XML in the lib and include
directories:
make install
Once you have installed it, use the "-lmxml" option to link your application
against it.
DOCUMENTATION
The documentation is available in the "doc" subdirectory in the files
"mxml.html" (HTML) and "mxml.pdf" (PDF). You can also look at the
"testmxml.c" and "mxmldoc.c" source files for examples of using Mini-XML.
Mini-XML provides a single header file which you include:
#include <mxml.h>
Nodes are defined by the "mxml_node_t" structure; the "type" member defines
the node type (element, integer, opaque, real, or text) which determines
which value you want to look at in the "value" union. New nodes can be
created using the "mxmlNewElement()", "mxmlNewInteger()", "mxmlNewOpaque()",
"mxmlNewReal()", and "mxmlNewText()" functions. Only elements can have
child nodes, and the top node must be an element, usually "?xml".
You load an XML file using the "mxmlLoadFile()" function:
FILE *fp;
mxml_node_t *tree;
fp = fopen("filename.xml", "r");
tree = mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK);
fclose(fp);
Similarly, you save an XML file using the "mxmlSaveFile()" function:
FILE *fp;
mxml_node_t *tree;
fp = fopen("filename.xml", "w");
mxmlSaveFile(tree, fp, MXML_NO_CALLBACK);
fclose(fp);
The "mxmlLoadString()", "mxmlSaveAllocString()", and "mxmlSaveString()"
functions load XML node trees from and save XML node trees to strings:
char buffer[8192];
char *ptr;
mxml_node_t *tree;
...
tree = mxmlLoadString(NULL, buffer, MXML_NO_CALLBACK);
...
mxmlSaveString(tree, buffer, sizeof(buffer), MXML_NO_CALLBACK);
...
ptr = mxmlSaveAllocString(tree, MXML_NO_CALLBACK);
You can find a named element/node using the "mxmlFindElement()" function:
mxml_node_t *node = mxmlFindElement(tree, tree, "name", "attr",
"value", MXML_DESCEND);
The "name", "attr", and "value" arguments can be passed as NULL to act as
wildcards, e.g.:
/* Find the first "a" element */
node = mxmlFindElement(tree, tree, "a", NULL, NULL, MXML_DESCEND);
/* Find the first "a" element with "href" attribute */
node = mxmlFindElement(tree, tree, "a", "href", NULL, MXML_DESCEND);
/* Find the first "a" element with "href" to a URL */
node = mxmlFindElement(tree, tree, "a", "href",
"http://www.minixml.org/",
MXML_DESCEND);
/* Find the first element with a "src" attribute*/
node = mxmlFindElement(tree, tree, NULL, "src", NULL, MXML_DESCEND);
/* Find the first element with a "src" = "foo.jpg" */
node = mxmlFindElement(tree, tree, NULL, "src", "foo.jpg",
MXML_DESCEND);
You can also iterate with the same function:
mxml_node_t *node;
for (node = mxmlFindElement(tree, tree, "name", NULL, NULL,
MXML_DESCEND);
node != NULL;
node = mxmlFindElement(node, tree, "name", NULL, NULL,
MXML_DESCEND))
{
... do something ...
}
The "mxmlFindPath()" function finds the (first) value node under a specific
element using a "path":
mxml_node_t *value = mxmlFindPath(tree, "path/to/*/foo/bar");
The "mxmlGetInteger()", "mxmlGetOpaque()", "mxmlGetReal()", and
"mxmlGetText()" functions retrieve the value from a node:
mxml_node_t *node;
int intvalue = mxmlGetInteger(node);
const char *opaquevalue = mxmlGetOpaque(node);
double realvalue = mxmlGetReal(node);
int whitespacevalue;
const char *textvalue = mxmlGetText(node, &whitespacevalue);
Finally, once you are done with the XML data, use the "mxmlDelete()"
function to recursively free the memory that is used for a particular node
or the entire tree:
mxmlDelete(tree);
GETTING HELP AND REPORTING PROBLEMS
The Mini-XML project page provides access to a discussion forum and bug
reporting page:
http://www.msweet.org/projects.php/Mini-XML
LEGAL STUFF
The Mini-XML library is Copyright 2003-2016 by Michael R Sweet. License
terms are described in the file "COPYING".

188
README.md Normal file
View File

@ -0,0 +1,188 @@
# Mini-XML Version 2.11
Mini-XML is a small XML parsing library that you can use to read XML data files
or strings in your application without requiring large non-standard libraries.
Mini-XML only requires a "make" program and an ANSI C compatible compiler - GCC
works, as do most vendors' ANSI C compilers.
Mini-XML provides the following functionality:
- Reading of UTF-8 and UTF-16 and writing of UTF-8 encoded XML files and
strings.
- Data is stored in a linked-list tree structure, preserving the XML data
hierarchy.
- SAX (streamed) reading of XML files and strings to minimize memory usage.
- Supports arbitrary element names, attributes, and attribute values with no
preset limits, just available memory.
- Supports integer, real, opaque ("cdata"), and text data types in "leaf" nodes.
- Functions for creating and managing trees of data.
- "Find" and "walk" functions for easily locating and navigating trees of data.
Mini-XML doesn't do validation or other types of processing on the data
based upon schema files or other sources of definition information.
## Building Mini-XML
Mini-XML comes with an autoconf-based configure script; just type the
following command to get things going:
./configure
The default install prefix is `/usr/local`, which can be overridden using the
`--prefix` option:
./configure --prefix=/foo
Other configure options can be found using the `--help` option:
./configure --help
Once you have configured the software, type `make` to do the build and run
the test program to verify that things are working, as follows:
make
If you are using Mini-XML under Microsoft Windows with Visual C++, use the
included project files in the `vcnet` subdirectory to build the library
instead. Note: The static library on Windows is NOT thread-safe.
## Installing Mini-XML
The `install` target will install Mini-XML in the lib and include
directories:
make install
Once you have installed it, use the `-lmxml` option to link your application
against it.
## Documentation
The documentation is available in the `doc` subdirectory in the files
`mxml.html` (HTML) and `mxml.pdf` (PDF). You can also look at the
`testmxml.c` and `mxmldoc.c` source files for examples of using Mini-XML.
Mini-XML provides a single header file which you include:
#include <mxml.h>
Nodes are defined by the `mxml_node_t` structure; the `type` member defines the
node type (`element`, `integer`, `opaque`, `real`, or `text`) which determines
which value you want to look at in the `value` union. New nodes can be created
using the `mxmlNewElement()`, `mxmlNewInteger()`, `mxmlNewOpaque()`,
`mxmlNewReal()`, and `mxmlNewText()` functions. Only elements can have child
nodes, and the top node must be an element, usually "?xml".
You load an XML file using the `mxmlLoadFile()` function:
FILE *fp;
mxml_node_t *tree;
fp = fopen("filename.xml", "r");
tree = mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK);
fclose(fp);
Similarly, you save an XML file using the `mxmlSaveFile()` function:
FILE *fp;
mxml_node_t *tree;
fp = fopen("filename.xml", "w");
mxmlSaveFile(tree, fp, MXML_NO_CALLBACK);
fclose(fp);
The `mxmlLoadString()`, `mxmlSaveAllocString()`, and `mxmlSaveString()`
functions load XML node trees from and save XML node trees to strings:
char buffer[8192];
char *ptr;
mxml_node_t *tree;
...
tree = mxmlLoadString(NULL, buffer, MXML_NO_CALLBACK);
...
mxmlSaveString(tree, buffer, sizeof(buffer), MXML_NO_CALLBACK);
...
ptr = mxmlSaveAllocString(tree, MXML_NO_CALLBACK);
You can find a named element/node using the `mxmlFindElement()` function:
mxml_node_t *node = mxmlFindElement(tree, tree, "name", "attr",
"value", MXML_DESCEND);
The `name`, `attr`, and `value` arguments can be passed as `NULL` to act as
wildcards, e.g.:
/* Find the first "a" element */
node = mxmlFindElement(tree, tree, "a", NULL, NULL, MXML_DESCEND);
/* Find the first "a" element with "href" attribute */
node = mxmlFindElement(tree, tree, "a", "href", NULL, MXML_DESCEND);
/* Find the first "a" element with "href" to a URL */
node = mxmlFindElement(tree, tree, "a", "href",
"http://www.minixml.org/",
MXML_DESCEND);
/* Find the first element with a "src" attribute*/
node = mxmlFindElement(tree, tree, NULL, "src", NULL, MXML_DESCEND);
/* Find the first element with a "src" = "foo.jpg" */
node = mxmlFindElement(tree, tree, NULL, "src", "foo.jpg",
MXML_DESCEND);
You can also iterate with the same function:
mxml_node_t *node;
for (node = mxmlFindElement(tree, tree, "name", NULL, NULL,
MXML_DESCEND);
node != NULL;
node = mxmlFindElement(node, tree, "name", NULL, NULL,
MXML_DESCEND))
{
... do something ...
}
The `mxmlFindPath()` function finds the (first) value node under a specific
element using an XPath:
mxml_node_t *value = mxmlFindPath(tree, "path/to/*/foo/bar");
The `mxmlGetInteger()`, `mxmlGetOpaque()`, `mxmlGetReal()`, and
`mxmlGetText()` functions retrieve the value from a node:
mxml_node_t *node;
int intvalue = mxmlGetInteger(node);
const char *opaquevalue = mxmlGetOpaque(node);
double realvalue = mxmlGetReal(node);
int whitespacevalue;
const char *textvalue = mxmlGetText(node, &whitespacevalue);
Finally, once you are done with the XML data, use the `mxmlDelete()`
function to recursively free the memory that is used for a particular node
or the entire tree:
mxmlDelete(tree);
## Getting Help And Reporting Problems
The Mini-XML project page provides access to the Github issue tracking page:
https://michaelrsweet.github.io/mxml
## Legal Stuff
The Mini-XML library is Copyright 2003-2017 by Michael R Sweet. License terms
are described in the file "COPYING".