Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the names of Apple Computer, Inc. ("Apple") or The Mozilla
Foundation ("Mozilla") nor the names of their contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY APPLE, MOZILLA AND THEIR
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL APPLE, MOZILLA OR THEIR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations under
the License.
The Original Code is mozilla.org code.
The Initial Developer of the Original Code is Netscape Communications
Corporation.
Portions created by the Initial Developer are Copyright (C) 1998 the Initial
Developer. All Rights Reserved.
Contributor(s):
Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable
instead of those above. If you wish to allow use of your version of this file
only under the terms of either the GPL or the LGPL, and not to allow
others to use your version of this file under the terms of the MPL, indicate
your decision by deleting the provisions above and replace them with the
notice and other provisions required by the GPL or the LGPL. If you do
not delete the provisions above, a recipient may use your version of this
file under the terms of any one of the MPL, the GPL or the LGPL.
TinyXML
TinyXML is a simple, small, C++ XML parser that can be easily integrated
into other programs.
What it does.
In brief, TinyXML parses an XML document, and builds from that a
Document Object Model (DOM) that can be read, modified, and saved.
XML stands for "eXtensible Markup Language." It allows you to create
your own document markups. Where HTML does a very good job of
marking documents for browsers, XML allows you to define any kind of
document markup, for example a document that describes a "to do" list
for an organizer application. XML is a very structured and convenient
format. All those random file formats created to store application data
can all be replaced with XML. One parser for everything. The best place
for the complete, correct, and quite frankly hard to read spec is at http://
www.w3.org/TR/2004/REC-xml-20040204/. An intro to XML (that I really
like) can be found at http://skew.org/xml/tutorial. There are different ways
to access and interact with XML data. TinyXML uses a Document Object
Model (DOM), meaning the XML data is parsed into a C++ objects that
can be browsed and manipulated, and then written to disk or another
output stream. You can also construct an XML document from scratch
with C++ objects and write this to disk or another output stream.
TinyXML is designed to be easy and fast to learn. It is two headers and
four cpp files. Simply add these to your project and off you go. There is
an example file - xmltest.cpp - to get you started. TinyXML is released
under the ZLib license, so you can use it in open source or commercial
code. The details of the license are at the top of every source file.
TinyXML attempts to be a flexible parser, but with truly correct and
compliant XML output. TinyXML should compile on any reasonably C++
compliant system. It does not rely on exceptions or RTTI. It can be
compiled with or without STL support. TinyXML fully supports the UTF-8
encoding, and the first 64k character entities.
What it doesn't do.
TinyXML doesn't parse or use DTDs (Document Type Definitions) or
XSLs (eXtensible Stylesheet Language.) There are other parsers out there
(check out www.sourceforge.org, search for XML) that are much more
fully featured. But they are also much bigger, take longer to set up in your
project, have a higher learning curve, and often have a more restrictive
license. If you are working with browsers or have more complete XML
needs, TinyXML is not the parser for you. The following DTD syntax will
not parse at this time in TinyXML: @verbatim ]> @endverbatim because
TinyXML sees this as a !DOCTYPE node with an illegally embedded
!ELEMENT node. This may be addressed in the future.
Tutorials.
For the impatient, here is a tutorial to get you going. A great way to get
started, but it is worth your time to read this (very short) manual
completely. - @subpage tutorial0
Code Status.
TinyXML is mature, tested code. It is very stable. If you find bugs, please
file a bug report on the sourceforge web site (www.sourceforge.net/
projects/tinyxml). We'll get them straightened out as soon as possible.
There are some areas of improvement; please check sourceforge if you
are interested in working on TinyXML.
Related Projects
TinyXML projects you may find useful! (Descriptions provided by the
projects.)
• TinyXPath (http://tinyxpath.sourceforge.net). TinyXPath is a small
footprint XPath syntax decoder, written in C++.
• + (http://code.google.com/p/ticpp/). + is a
completely new interface to TinyXML that uses MANY of the C++
strengths. Templates, exceptions, and much better error handling.
Features
Using STL
TinyXML can be compiled to use or not use STL. When using STL,
TinyXML uses the std::string class, and fully supports std::istream,
std::ostream, operator<<, and operator>>. Many API methods have
both 'const char*' and 'const std::string&' forms. When STL support is
compiled out, no STL files are included whatsoever. All the string classes
are implemented by TinyXML itself. API methods all use the 'const char*'
form for input. Use the compile time #define: TIXML_USE_STL to
compile one version or the other. This can be passed by the compiler, or
set as the first line of "tinyxml.h". Note: If compiling the test code in Linux,
setting the environment variable TINYXML_USE_STL=YES/NO will
control STL compilation. In the Windows project file, STL and non STL
targets are provided. In your project, It's probably easiest to add the line
"#define TIXML_USE_STL" as the first line of tinyxml.h.
UTF-8
TinyXML supports UTF-8 allowing to manipulate XML files in any
language. TinyXML also supports "legacy mode" - the encoding used
before UTF-8 support and probably best described as "extended ascii".
Normally, TinyXML will try to detect the correct encoding and use it.
However, by setting the value of TIXML_DEFAULT_ENCODING in the
header file, TinyXML can be forced to always use one encoding. TinyXML
will assume Legacy Mode until one of the following occurs: