{"id":13417860,"url":"https://github.com/leethomason/tinyxml2","last_synced_at":"2025-05-11T03:40:17.582Z","repository":{"id":2563272,"uuid":"3542607","full_name":"leethomason/tinyxml2","owner":"leethomason","description":"TinyXML2 is a simple, small, efficient, C++ XML parser that can be easily integrated into other programs.","archived":false,"fork":false,"pushed_at":"2025-03-15T21:46:14.000Z","size":3575,"stargazers_count":5327,"open_issues_count":117,"forks_count":1880,"subscribers_count":223,"default_branch":"master","last_synced_at":"2025-05-11T03:40:01.371Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leethomason.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-02-25T05:15:50.000Z","updated_at":"2025-05-11T01:19:10.000Z","dependencies_parsed_at":"2023-02-19T13:16:22.368Z","dependency_job_id":"e3a1448d-134d-424f-a8c2-e28e0cee4c94","html_url":"https://github.com/leethomason/tinyxml2","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leethomason%2Ftinyxml2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leethomason%2Ftinyxml2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leethomason%2Ftinyxml2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leethomason%2Ftinyxml2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leethomason","download_url":"https://codeload.github.com/leethomason/tinyxml2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253514555,"owners_count":21920334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T22:00:54.225Z","updated_at":"2025-05-11T03:40:17.555Z","avatar_url":"https://github.com/leethomason.png","language":"C++","readme":"TinyXML-2\n=========\n\n[![Test](https://github.com/leethomason/tinyxml2/actions/workflows/test.yml/badge.svg)](https://github.com/leethomason/tinyxml2/actions/workflows/test.yml)\n\nTinyXML-2 is a simple, small, efficient, C++ XML parser that can be\neasily integrated into other programs.\n\nThe master is hosted on github:\nhttps://github.com/leethomason/tinyxml2\n\nThe online HTML version of these docs:\nhttp://leethomason.github.io/tinyxml2/\n\nExamples are in the \"related pages\" tab of the HTML docs.\n\nWhat it does.\n-------------\n\nIn brief, TinyXML-2 parses an XML document, and builds from that a\nDocument Object Model (DOM) that can be read, modified, and saved.\n\nXML stands for \"eXtensible Markup Language.\" It is a general purpose\nhuman and machine readable markup language to describe arbitrary data.\nAll those random file formats created to store application data can\nall be replaced with XML. One parser for everything.\n\nhttp://en.wikipedia.org/wiki/XML\n\nThere are different ways to access and interact with XML data.\nTinyXML-2 uses a Document Object Model (DOM), meaning the XML data is parsed\ninto a C++ objects that can be browsed and manipulated, and then\nwritten to disk or another output stream. You can also construct an XML document\nfrom scratch with C++ objects and write this to disk or another output\nstream. You can even use TinyXML-2 to stream XML programmatically from\ncode without creating a document first.\n\nTinyXML-2 is designed to be easy and fast to learn. It is one header and\none cpp file. Simply add these to your project and off you go.\nThere is an example file - xmltest.cpp - to get you started.\n\nTinyXML-2 is released under the ZLib license,\nso you can use it in open source or commercial code. The details\nof the license are at the top of every source file.\n\nTinyXML-2 attempts to be a flexible parser, but with truly correct and\ncompliant XML output. TinyXML-2 should compile on any reasonably C++\ncompliant system. It does not rely on exceptions, RTTI, or the STL.\n\nWhat it doesn't do.\n-------------------\n\nTinyXML-2 doesn't parse or use DTDs (Document Type Definitions) or XSLs\n(eXtensible Stylesheet Language.) There are other parsers out there\nthat are much more fully featured. But they are generally bigger and\nmore difficult to use. If you are working with\nbrowsers or have more complete XML needs, TinyXML-2 is not the parser for you.\n\nTinyXML-1 vs. TinyXML-2\n-----------------------\n\nTinyXML-2 long been the focus of all development. It is well tested \nand should be used instead of TinyXML-1.\n\nTinyXML-2 uses a similar API to TinyXML-1 and the same\nrich test cases. But the implementation of the parser is completely re-written\nto make it more appropriate for use in a game. It uses less memory, is faster,\nand uses far fewer memory allocations.\n\nTinyXML-2 has no requirement or support for STL.\n\nFeatures\n--------\n\n### Code Page\n\nTinyXML-2 uses UTF-8 exclusively when interpreting XML. All XML is assumed to\nbe UTF-8.\n\nFilenames for loading / saving are passed unchanged to the underlying OS.\n\n### Memory Model\n\nAn XMLDocument is a C++ object like any other, that can be on the stack, or\nnew'd and deleted on the heap.\n\nHowever, any sub-node of the Document, XMLElement, XMLText, etc, can only\nbe created by calling the appropriate XMLDocument::NewElement, NewText, etc.\nmethod. Although you have pointers to these objects, they are still owned\nby the Document. When the Document is deleted, so are all the nodes it contains.\n\n### White Space\n\n#### Whitespace Preservation (default, PRESERVE_WHITESPACE)\n\nMicrosoft has an excellent article on white space: http://msdn.microsoft.com/en-us/library/ms256097.aspx\n\nBy default, TinyXML-2 preserves white space in a (hopefully) sane way that is almost compliant with the\nspec. (TinyXML-1 used a completely different model, much more similar to 'collapse', below.)\n\nAs a first step, all newlines / carriage-returns / line-feeds are normalized to a\nline-feed character, as required by the XML spec.\n\nWhite space in text is preserved. For example:\n\n\t\u003celement\u003e Hello,  World\u003c/element\u003e\n\nThe leading space before the \"Hello\" and the double space after the comma are\npreserved. Line-feeds are preserved, as in this example:\n\n\t\u003celement\u003e Hello again,\n\t          World\u003c/element\u003e\n\nHowever, white space between elements is **not** preserved. Although not strictly\ncompliant, tracking and reporting inter-element space is awkward, and not normally\nvaluable. TinyXML-2 sees these as the same XML:\n\n\t\u003cdocument\u003e\n\t\t\u003cdata\u003e1\u003c/data\u003e\n\t\t\u003cdata\u003e2\u003c/data\u003e\n\t\t\u003cdata\u003e3\u003c/data\u003e\n\t\u003c/document\u003e\n\n\t\u003cdocument\u003e\u003cdata\u003e1\u003c/data\u003e\u003cdata\u003e2\u003c/data\u003e\u003cdata\u003e3\u003c/data\u003e\u003c/document\u003e\n\n#### Whitespace Collapse (COLLAPSE_WHITESPACE)\n\nFor some applications, it is preferable to collapse whitespace. Collapsing\nwhitespace gives you \"HTML-like\" behavior, which is sometimes more suitable\nfor hand typed documents.\n\nTinyXML-2 supports this with the 'whitespace' parameter to the XMLDocument constructor.\n(The default is to preserve whitespace, as described above.)\n\nHowever, you may also use COLLAPSE_WHITESPACE, which will:\n\n* Remove leading and trailing whitespace\n* Convert newlines and line-feeds into a space character\n* Collapse a run of any number of space characters into a single space character\n\nNote that (currently) there is a performance impact for using COLLAPSE_WHITESPACE.\nIt essentially causes the XML to be parsed twice.\n\n#### Pedantic Whitespace (PEDANTIC_WHITESPACE)\n\nFor applications that need to know about text nodes that are composed entirely of \nwhitespace, PEDANTIC_WHITESPACE is available. PEDANTIC_WHITESPACE maintains all the\nwhilespace between elements. \n\nPEDANTIC_WHITESPACE is a new mode and not as tested as the other whitespace modes.\n\n### Error Reporting\n\nTinyXML-2 reports the line number of any errors in an XML document that\ncannot be parsed correctly. In addition, all nodes (elements, declarations,\ntext, comments etc.) and attributes have a line number recorded as they are parsed.\nThis allows an application that performs additional validation of the parsed\nXML document (e.g. application-implemented DTD validation) to report\nline number information for error messages.\n\n### Entities\n\nTinyXML-2 recognizes the pre-defined \"character entities\", meaning special\ncharacters. Namely:\n\n\t\u0026amp;\t\u0026\n\t\u0026lt;\t\u003c\n\t\u0026gt;\t\u003e\n\t\u0026quot;\t\"\n\t\u0026apos;\t'\n\nThese are recognized when the XML document is read, and translated to their\nUTF-8 equivalents. For instance, text with the XML of:\n\n\tFar \u0026amp; Away\n\nwill have the Value() of \"Far \u0026 Away\" when queried from the XMLText object,\nand will be written back to the XML stream/file as an ampersand.\n\nAdditionally, any character can be specified by its Unicode code point:\nThe syntax `\u0026#xA0;` or `\u0026#160;` are both to the non-breaking space character.\nThis is called a 'numeric character reference'. Any numeric character reference\nthat isn't one of the special entities above, will be read, but written as a\nregular code point. The output is correct, but the entity syntax isn't preserved.\n\n### Printing\n\n#### Print to file\nYou can directly use the convenience function:\n\n\tXMLDocument doc;\n\t...\n\tdoc.SaveFile( \"foo.xml\" );\n\nOr the XMLPrinter class:\n\n\tXMLPrinter printer( fp );\n\tdoc.Print( \u0026printer );\n\n#### Print to memory\nPrinting to memory is supported by the XMLPrinter.\n\n\tXMLPrinter printer;\n\tdoc.Print( \u0026printer );\n\t// printer.CStr() has a const char* to the XML\n\n#### Print without an XMLDocument\n\nWhen loading, an XML parser is very useful. However, sometimes\nwhen saving, it just gets in the way. The code is often set up\nfor streaming, and constructing the DOM is just overhead.\n\nThe Printer supports the streaming case. The following code\nprints out a trivially simple XML file without ever creating\nan XML document.\n\n\tXMLPrinter printer( fp );\n\tprinter.OpenElement( \"foo\" );\n\tprinter.PushAttribute( \"foo\", \"bar\" );\n\tprinter.CloseElement();\n\nExamples\n--------\n\n#### Load and parse an XML file.\n\n\t/* ------ Example 1: Load and parse an XML file. ---- */\n\t{\n\t\tXMLDocument doc;\n\t\tdoc.LoadFile( \"dream.xml\" );\n\t}\n\n#### Lookup information.\n\n\t/* ------ Example 2: Lookup information. ---- */\n\t{\n\t\tXMLDocument doc;\n\t\tdoc.LoadFile( \"dream.xml\" );\n\n\t\t// Structure of the XML file:\n\t\t// - Element \"PLAY\"      the root Element, which is the\n\t\t//                       FirstChildElement of the Document\n\t\t// - - Element \"TITLE\"   child of the root PLAY Element\n\t\t// - - - Text            child of the TITLE Element\n\n\t\t// Navigate to the title, using the convenience function,\n\t\t// with a dangerous lack of error checking.\n\t\tconst char* title = doc.FirstChildElement( \"PLAY\" )-\u003eFirstChildElement( \"TITLE\" )-\u003eGetText();\n\t\tprintf( \"Name of play (1): %s\\n\", title );\n\n\t\t// Text is just another Node to TinyXML-2. The more\n\t\t// general way to get to the XMLText:\n\t\tXMLText* textNode = doc.FirstChildElement( \"PLAY\" )-\u003eFirstChildElement( \"TITLE\" )-\u003eFirstChild()-\u003eToText();\n\t\ttitle = textNode-\u003eValue();\n\t\tprintf( \"Name of play (2): %s\\n\", title );\n\t}\n\nUsing and Installing\n--------------------\n\nThere are 2 files in TinyXML-2:\n* tinyxml2.cpp\n* tinyxml2.h\n\nAnd additionally a test file:\n* xmltest.cpp\n\nGenerally speaking, the intent is that you simply include the tinyxml2.cpp and \ntinyxml2.h files in your project and build with your other source code.\n\nThere is also a CMake build included. CMake is the general build for TinyXML-2.\n\n(Additional build systems are costly to maintain, and tend to bit-rot. They are\nbeing removed over time.)\n\nBuilding TinyXML-2 - Using vcpkg\n--------------------------------\n\nYou can download and install TinyXML-2 using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:\n\n    git clone https://github.com/Microsoft/vcpkg.git\n    cd vcpkg\n    ./bootstrap-vcpkg.sh\n    ./vcpkg integrate install\n    ./vcpkg install tinyxml2\n\nThe TinyXML-2 port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.\n\nVersioning\n----------\n\nTinyXML-2 uses semantic versioning. http://semver.org/ Releases are now tagged in github.\n\nNote that the major version will (probably) change fairly rapidly. API changes are fairly\ncommon.\n\nLicense\n-------\n\nTinyXML-2 is released under the zlib license:\n\nThis software is provided 'as-is', without any express or implied\nwarranty. In no event will the authors be held liable for any\ndamages arising from the use of this software.\n\nPermission is granted to anyone to use this software for any\npurpose, including commercial applications, and to alter it and\nredistribute it freely, subject to the following restrictions:\n\n1. The origin of this software must not be misrepresented; you must\nnot claim that you wrote the original software. If you use this\nsoftware in a product, an acknowledgment in the product documentation\nwould be appreciated but is not required.\n2. Altered source versions must be plainly marked as such, and\nmust not be misrepresented as being the original software.\n3. This notice may not be removed or altered from any source\ndistribution.\n\nContributors\n------------\n\nThanks very much to everyone who sends suggestions, bugs, ideas, and\nencouragement. It all helps, and makes this project fun.\n\nThe original TinyXML-1 has many contributors, who all deserve thanks\nin shaping what is a very successful library. Extra thanks to Yves\nBerquin and Andrew Ellerton who were key contributors.\n\nTinyXML-2 grew from that effort. Lee Thomason is the original author\nof TinyXML-2 (and TinyXML-1) but TinyXML-2 has been and is being improved\nby many contributors.\n\nThanks to John Mackay at http://john.mackay.rosalilastudio.com for the TinyXML-2 logo!\n\n\n","funding_links":[],"categories":["TODO scan for Android support in followings","XML","C++","排序","Processing Libraries","Libraries"],"sub_categories":["XML","Libraries","C++"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleethomason%2Ftinyxml2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleethomason%2Ftinyxml2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleethomason%2Ftinyxml2/lists"}