?? index.html
字號:
Generates condensed output, intended for network transmission rather than readability. Depending on your system's implementation of the ostream class, these may be somewhat slower. (Or may not.) Not tolerant of ill formed XML: a document should contain the correct one root element. Additional root level elements will not be streamed out.<p>C++ style input:<ul><li>based on std::istream</li><li>operator>></li></ul><p>Reads XML from a stream, making it useful for network transmission. The tricky part is knowing when the XML document is complete, since there will almost certainly be other data in the stream. TinyXML will assume the XML data is complete after it reads the root element. Put another way, documents that are ill-constructed with more than one root element will not read correctly. Also note that operator>> is somewhat slower than Parse, due to both implementation of the STL and limitations of TinyXML.<p><h3>White space </h3><p>The world simply does not agree on whether white space should be kept, or condensed. For example, pretend the '_' is a space, and look at "Hello____world". HTML, and at least some XML parsers, will interpret this as "Hello_world". They condense white space. Some XML parsers do not, and will leave it as "Hello____world". (Remember to keep pretending the _ is a space.) Others suggest that __Hello___world__ should become Hello___world.<p>It's an issue that hasn't been resolved to my satisfaction. TinyXML supports the first 2 approaches. Call <a class="el" href="classTiXmlBase.html#0f799ec645bfb8d8a969e83478f379c1">TiXmlBase::SetCondenseWhiteSpace( bool )</a> to set the desired behavior. The default is to condense white space.<p>If you change the default, you should call <a class="el" href="classTiXmlBase.html#0f799ec645bfb8d8a969e83478f379c1">TiXmlBase::SetCondenseWhiteSpace( bool )</a> before making any calls to Parse XML data, and I don't recommend changing it after it has been set.<p><h3>Handles </h3><p>Where browsing an XML document in a robust way, it is important to check for null returns from method calls. An error safe implementation can generate a lot of code like:<p><div class="fragment"><pre class="fragment">TiXmlElement* root = document.FirstChildElement( "Document" );if ( root ){ TiXmlElement* element = root->FirstChildElement( "Element" ); if ( element ) { TiXmlElement* child = element->FirstChildElement( "Child" ); if ( child ) { TiXmlElement* child2 = child->NextSiblingElement( "Child" ); if ( child2 ) { // Finally do something useful.</pre></div><p>Handles have been introduced to clean this up. Using the <a class="el" href="classTiXmlHandle.html">TiXmlHandle</a> class, the previous code reduces to:<p><div class="fragment"><pre class="fragment">TiXmlHandle docHandle( &document );TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement();if ( child2 ){ // do something useful</pre></div><p>Which is much easier to deal with. See <a class="el" href="classTiXmlHandle.html">TiXmlHandle</a> for more information.<p><h3>Row and Column tracking </h3><p>Being able to track nodes and attributes back to their origin location in source files can be very important for some applications. Additionally, knowing where parsing errors occured in the original source can be very time saving.<p>TinyXML can tracks the row and column origin of all nodes and attributes in a text file. The <a class="el" href="classTiXmlBase.html#024bceb070188df92c2a8d8852dd0853">TiXmlBase::Row()</a> and <a class="el" href="classTiXmlBase.html#b54bfb9b70fe6dd276e7b279cab7f003">TiXmlBase::Column()</a> methods return the origin of the node in the source text. The correct tabs can be configured in <a class="el" href="classTiXmlDocument.html#51dac56316f89b35bdb7d0d433ba988e">TiXmlDocument::SetTabSize()</a>.<p><h2>Using and Installing </h2><p>To Compile and Run xmltest:<p>A Linux Makefile and a Windows Visual C++ .dsw file is provided. Simply compile and run. It will write the file demotest.xml to your disk and generate output on the screen. It also tests walking the DOM by printing out the number of nodes found using different techniques.<p>The Linux makefile is very generic and runs on many systems - it is currently tested on mingw and MacOSX. You do not need to run 'make depend'. The dependecies have been hard coded.<p><h3>Windows project file for VC6</h3><p><ul><li>tinyxml: tinyxml library, non-STL </li><li>tinyxmlSTL: tinyxml library, STL </li><li>tinyXmlTest: test app, non-STL </li><li>tinyXmlTestSTL: test app, STL </li></ul><p><h3>Makefile</h3><p>At the top of the makefile you can set:<p>PROFILE, DEBUG, and TINYXML_USE_STL. Details (such that they are) are in the makefile.<p>In the tinyxml directory, type "make clean" then "make". The executable file 'xmltest' will be created.<p><h3>To Use in an Application:</h3><p>Add tinyxml.cpp, <a class="el" href="tinyxml_8h-source.html">tinyxml.h</a>, tinyxmlerror.cpp, tinyxmlparser.cpp, tinystr.cpp, and <a class="el" href="tinystr_8h-source.html">tinystr.h</a> to your project or make file. That's it! It should compile on any reasonably compliant C++ system. You do not need to enable exceptions or RTTI for TinyXML.<p><h2>How TinyXML works. </h2><p>An example is probably the best way to go. Take: <div class="fragment"><pre class="fragment"> <?xml version="1.0" standalone=no> <!-- Our to do list data --> <ToDo> <Item priority="1"> Go to the <bold>Toy store!</bold></Item> <Item priority="2"> Do bills</Item> </ToDo></pre></div><p>Its not much of a To Do list, but it will do. To read this file (say "demo.xml") you would create a document, and parse it in: <div class="fragment"><pre class="fragment"> TiXmlDocument doc( "demo.xml" ); doc.LoadFile();</pre></div><p>And its ready to go. Now lets look at some lines and how they relate to the DOM.<p><div class="fragment"><pre class="fragment"><?xml version="1.0" standalone=no></pre></div><p>The first line is a declaration, and gets turned into the <a class="el" href="classTiXmlDeclaration.html">TiXmlDeclaration</a> class. It will be the first child of the document node.<p>This is the only directive/special tag parsed by by TinyXML. Generally directive tags are stored in <a class="el" href="classTiXmlUnknown.html">TiXmlUnknown</a> so the commands wont be lost when it is saved back to disk.<p><div class="fragment"><pre class="fragment"><!-- Our to do list data --></pre></div><p>A comment. Will become a <a class="el" href="classTiXmlComment.html">TiXmlComment</a> object.<p><div class="fragment"><pre class="fragment"><ToDo></pre></div><p>The "ToDo" tag defines a <a class="el" href="classTiXmlElement.html">TiXmlElement</a> object. This one does not have any attributes, but does contain 2 other elements.<p><div class="fragment"><pre class="fragment"><Item priority="1"> </pre></div><p>Creates another <a class="el" href="classTiXmlElement.html">TiXmlElement</a> which is a child of the "ToDo" element. This element has 1 attribute, with the name "priority" and the value "1".<p><div class="fragment"><pre class="fragment">Go to the</pre></div><p>A <a class="el" href="classTiXmlText.html">TiXmlText</a>. This is a leaf node and cannot contain other nodes. It is a child of the "Item" <a class="el" href="classTiXmlElement.html">TiXmlElement</a>.<p><div class="fragment"><pre class="fragment"><bold></pre></div><p>Another <a class="el" href="classTiXmlElement.html">TiXmlElement</a>, this one a child of the "Item" element.<p>Etc.<p>Looking at the entire object tree, you end up with: <div class="fragment"><pre class="fragment">TiXmlDocument "demo.xml" TiXmlDeclaration "version='1.0'" "standalone=no" TiXmlComment " Our to do list data" TiXmlElement "ToDo" TiXmlElement "Item" Attribtutes: priority = 1 TiXmlText "Go to the " TiXmlElement "bold" TiXmlText "Toy store!" TiXmlElement "Item" Attributes: priority=2 TiXmlText "Do bills"</pre></div><p><h2>Documentation </h2><p>The documentation is build with Doxygen, using the 'dox' configuration file.<p><h2>License </h2><p>TinyXML is released under the zlib license:<p>This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.<p>Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:<p>1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.<p>2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.<p>3. This notice may not be removed or altered from any source distribution.<p><h2>References </h2><p>The World Wide Web Consortium is the definitive standard body for XML, and there web pages contain huge amounts of information.<p>The definitive spec: <a href="http://www.w3.org/TR/2004/REC-xml-20040204/">http://www.w3.org/TR/2004/REC-xml-20040204/</a><p>I also recommend "XML Pocket Reference" by Robert Eckstein and published by OReilly...the book that got the whole thing started.<p><h2>Contributors, Contacts, and a Brief History </h2><p>Thanks very much to everyone who sends suggestions, bugs, ideas, and encouragement. It all helps, and makes this project fun. A special thanks to the contributors on the web pages that keep it lively.<p>So many people have sent in bugs and ideas, that rather than list here we try to give credit due in the "changes.txt" file.<p>TinyXML was originally written by Lee Thomason. (Often the "I" still in the documentation.) Lee reviews changes and releases new versions, with the help of Yves Berquin, Andrew Ellerton, and the tinyXml community.<p>We appreciate your suggestions, and would love to know if you use TinyXML. Hopefully you will enjoy it and find it useful. Please post questions, comments, file bugs, or contact us at:<p>www.sourceforge.net/projects/tinyxml<p>Lee Thomason, Yves Berquin, Andrew Ellerton <hr size="1"><address style="align: right;"><small>Generated on Tue Sep 19 19:04:34 2006 for TinyXml by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address></body></html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -