📄 classtixmldocument.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>TinyXml: TiXmlDocument Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.4 -->
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a></div>
<h1>TiXmlDocument Class Reference</h1><!-- doxytag: class="TiXmlDocument" --><!-- doxytag: inherits="TiXmlNode" -->Always the top level node.
<a href="#_details">More...</a>
<p>
<code>#include <<a class="el" href="tinyxml_8h-source.html">tinyxml.h</a>></code>
<p>
<p>Inheritance diagram for TiXmlDocument:
<p><center><img src="classTiXmlDocument.png" usemap="#TiXmlDocument_map" border="0" alt=""></center>
<map name="TiXmlDocument_map">
<area href="classTiXmlNode.html" alt="TiXmlNode" shape="rect" coords="0,56,99,80">
<area href="classTiXmlBase.html" alt="TiXmlBase" shape="rect" coords="0,0,99,24">
</map>
<a href="classTiXmlDocument-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a0"></a><!-- doxytag: member="TiXmlDocument::TiXmlDocument" ref="a0" args="()" -->
</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a0">TiXmlDocument</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Create an empty document, that has no name. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a1"></a><!-- doxytag: member="TiXmlDocument::TiXmlDocument" ref="a1" args="(const char *documentName)" -->
</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a1">TiXmlDocument</a> (const char *documentName)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Create a document with a name. The name of the document is also the filename of the xml. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a2"></a><!-- doxytag: member="TiXmlDocument::TiXmlDocument" ref="a2" args="(const std::string &documentName)" -->
</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a2">TiXmlDocument</a> (const std::string &documentName)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a6">LoadFile</a> (TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Load a file using the current document value. <a href="#a6"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a7"></a><!-- doxytag: member="TiXmlDocument::SaveFile" ref="a7" args="() const " -->
bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a7">SaveFile</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Save a file using the current document value. Returns true if successful. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a8"></a><!-- doxytag: member="TiXmlDocument::LoadFile" ref="a8" args="(const char *filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)" -->
bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a8">LoadFile</a> (const char *filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Load a file using the given filename. Returns true if successful. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a9"></a><!-- doxytag: member="TiXmlDocument::SaveFile" ref="a9" args="(const char *filename) const " -->
bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a9">SaveFile</a> (const char *filename) const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Save a file using the given filename. Returns true if successful. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a10">LoadFile</a> (FILE *, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Load a file using the given FILE*. <a href="#a10"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a11"></a><!-- doxytag: member="TiXmlDocument::SaveFile" ref="a11" args="(FILE *) const " -->
bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a11">SaveFile</a> (FILE *) const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Save a file using the given FILE*. Returns true if successful. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a12">LoadFile</a> (const std::string &filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a13"></a><!-- doxytag: member="TiXmlDocument::SaveFile" ref="a13" args="(const std::string &filename) const " -->
bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a13">SaveFile</a> (const std::string &filename) const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">< STL std::string version. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual const char * </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a14">Parse</a> (const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Parse the given null terminated block of xml data. <a href="#a14"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="classTiXmlElement.html">TiXmlElement</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a15">RootElement</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Get the root element -- the only top level element -- of the document. <a href="#a15"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a17">Error</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">If an error occurs, Error will be set to true. <a href="#a17"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a18"></a><!-- doxytag: member="TiXmlDocument::ErrorDesc" ref="a18" args="() const " -->
const char * </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a18">ErrorDesc</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Contains a textual (english) description of the error if one occurs. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a19">ErrorId</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Generally, you probably want the error string ( <a class="el" href="classTiXmlDocument.html#a18">ErrorDesc()</a> ). <a href="#a19"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a20">ErrorRow</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the location (if known) of the error. <a href="#a20"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a21"></a><!-- doxytag: member="TiXmlDocument::ErrorCol" ref="a21" args="()" -->
int </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a21">ErrorCol</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">The column where the error occured. See <a class="el" href="classTiXmlDocument.html#a20">ErrorRow()</a>. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a22">SetTabSize</a> (int _tabsize)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight"><a class="el" href="classTiXmlDocument.html#a22">SetTabSize()</a> allows the error reporting functions (<a class="el" href="classTiXmlDocument.html#a20">ErrorRow()</a> and <a class="el" href="classTiXmlDocument.html#a21">ErrorCol()</a>) to report the correct values for row and column. <a href="#a22"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a24">ClearError</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">If you have handled the error, it can be reset with this call. <a href="#a24"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a25"></a><!-- doxytag: member="TiXmlDocument::Print" ref="a25" args="() const " -->
void </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a25">Print</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Dump the document to standard out. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a26"></a><!-- doxytag: member="TiXmlDocument::Print" ref="a26" args="(FILE *cfile, int depth=0) const " -->
virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a26">Print</a> (FILE *cfile, int depth=0) const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Print this Document to a FILE stream. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a28"></a><!-- doxytag: member="TiXmlDocument::ToDocument" ref="a28" args="() const " -->
virtual const <a class="el" href="classTiXmlDocument.html">TiXmlDocument</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a28">ToDocument</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Cast to a more defined type. Will return null not of the requested type. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a29"></a><!-- doxytag: member="TiXmlDocument::ToDocument" ref="a29" args="()" -->
virtual <a class="el" href="classTiXmlDocument.html">TiXmlDocument</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#a29">ToDocument</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Cast to a more defined type. Will return null not of the requested type. <br></td></tr>
<tr><td colspan="2"><br><h2>Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual <a class="el" href="classTiXmlNode.html">TiXmlNode</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlDocument.html#b1">Clone</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Create an exact duplicate of this node and return it. <a href="#b1"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Always the top level node.
<p>
A document binds together all the XML pieces. It can be saved, loaded, and printed to the screen. The 'value' of a document node is the xml file name.
<p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="a24"></a><!-- doxytag: member="TiXmlDocument::ClearError" ref="a24" args="()" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">void TiXmlDocument::ClearError </td>
<td class="md" valign="top">( </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap><code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
If you have handled the error, it can be reset with this call.
<p>
The error state is automatically cleared if you Parse a new XML block. </td>
</tr>
</table>
<a class="anchor" name="b1"></a><!-- doxytag: member="TiXmlDocument::Clone" ref="b1" args="() const " --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">virtual <a class="el" href="classTiXmlNode.html">TiXmlNode</a>* TiXmlDocument::Clone </td>
<td class="md" valign="top">( </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap> const<code> [protected, virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
Create an exact duplicate of this node and return it.
<p>
The memory must be deleted by the caller.
<p>
Implements <a class="el" href="classTiXmlNode.html#a72">TiXmlNode</a>. </td>
</tr>
</table>
<a class="anchor" name="a17"></a><!-- doxytag: member="TiXmlDocument::Error" ref="a17" args="() const " --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">bool TiXmlDocument::Error </td>
<td class="md" valign="top">( </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap> const<code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
If an error occurs, Error will be set to true.
<p>
Also,<ul>
<li>The <a class="el" href="classTiXmlDocument.html#a19">ErrorId()</a> will contain the integer identifier of the error (not generally useful)</li><li>The <a class="el" href="classTiXmlDocument.html#a18">ErrorDesc()</a> method will return the name of the error. (very useful)</li><li>The <a class="el" href="classTiXmlDocument.html#a20">ErrorRow()</a> and <a class="el" href="classTiXmlDocument.html#a21">ErrorCol()</a> will return the location of the error (if known)</li></ul>
</td>
</tr>
</table>
<a class="anchor" name="a19"></a><!-- doxytag: member="TiXmlDocument::ErrorId" ref="a19" args="() const " --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">int TiXmlDocument::ErrorId </td>
<td class="md" valign="top">( </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap> const<code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
Generally, you probably want the error string ( <a class="el" href="classTiXmlDocument.html#a18">ErrorDesc()</a> ).
<p>
But if you prefer the ErrorId, this function will fetch it. </td>
</tr>
</table>
<a class="anchor" name="a20"></a><!-- doxytag: member="TiXmlDocument::ErrorRow" ref="a20" args="()" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">int TiXmlDocument::ErrorRow </td>
<td class="md" valign="top">( </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap><code> [inline]</code></td>
</tr>
</table>
</td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -