blob: 27b4bd9964387a576b6bd75f049635809edaa428 [file] [log] [blame]
<!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: TiXmlElement 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&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a></div>
<h1>TiXmlElement Class Reference</h1><!-- doxytag: class="TiXmlElement" --><!-- doxytag: inherits="TiXmlNode" -->The element is a container class.
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="tinyxml_8h-source.html">tinyxml.h</a>&gt;</code>
<p>
<p>Inheritance diagram for TiXmlElement:
<p><center><img src="classTiXmlElement.png" usemap="#TiXmlElement_map" border="0" alt=""></center>
<map name="TiXmlElement_map">
<area href="classTiXmlNode.html" alt="TiXmlNode" shape="rect" coords="0,56,87,80">
<area href="classTiXmlBase.html" alt="TiXmlBase" shape="rect" coords="0,0,87,24">
</map>
<a href="classTiXmlElement-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="TiXmlElement::TiXmlElement" ref="a0" args="(const char *in_value)" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a0">TiXmlElement</a> (const char *in_value)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Construct an element. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a1"></a><!-- doxytag: member="TiXmlElement::TiXmlElement" ref="a1" args="(const std::string &amp;_value)" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a1">TiXmlElement</a> (const std::string &amp;_value)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">std::string constructor. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a5"></a><!-- doxytag: member="TiXmlElement::Attribute" ref="a5" args="(const char *name) const " -->
const char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a5">Attribute</a> (const char *name) const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Given an attribute name, <a class="el" href="classTiXmlElement.html#a5">Attribute()</a> returns the value for the attribute of that name, or null if none exists. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">const char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a6">Attribute</a> (const char *name, int *i) const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Given an attribute name, <a class="el" href="classTiXmlElement.html#a5">Attribute()</a> returns the value for the attribute of that name, or null if none exists. <a href="#a6"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">const char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a7">Attribute</a> (const char *name, double *d) const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Given an attribute name, <a class="el" href="classTiXmlElement.html#a5">Attribute()</a> returns the value for the attribute of that name, or null if none exists. <a href="#a7"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a8">QueryIntAttribute</a> (const char *name, int *_value) const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">QueryIntAttribute examines the attribute - it is an alternative to the <a class="el" href="classTiXmlElement.html#a5">Attribute()</a> method with richer error checking. <a href="#a8"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a9"></a><!-- doxytag: member="TiXmlElement::QueryDoubleAttribute" ref="a9" args="(const char *name, double *_value) const " -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a9">QueryDoubleAttribute</a> (const char *name, double *_value) const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">QueryDoubleAttribute examines the attribute - see <a class="el" href="classTiXmlElement.html#a8">QueryIntAttribute()</a>. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a10"></a><!-- doxytag: member="TiXmlElement::QueryFloatAttribute" ref="a10" args="(const char *name, float *_value) const " -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a10">QueryFloatAttribute</a> (const char *name, float *_value) const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">QueryFloatAttribute examines the attribute - see <a class="el" href="classTiXmlElement.html#a8">QueryIntAttribute()</a>. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a11">SetAttribute</a> (const char *name, const char *_value)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Sets an attribute of name to a given value. <a href="#a11"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a17"></a><!-- doxytag: member="TiXmlElement::SetAttribute" ref="a17" args="(const std::string &amp;name, const std::string &amp;_value)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a17">SetAttribute</a> (const std::string &amp;name, const std::string &amp;_value)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">STL std::string form. STL std::string form. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a19">SetAttribute</a> (const char *name, int value)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Sets an attribute of name to a given value. <a href="#a19"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a20">SetDoubleAttribute</a> (const char *name, double value)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Sets an attribute of name to a given value. <a href="#a20"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a21"></a><!-- doxytag: member="TiXmlElement::RemoveAttribute" ref="a21" args="(const char *name)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a21">RemoveAttribute</a> (const char *name)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Deletes an attribute with the given name. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a22"></a><!-- doxytag: member="TiXmlElement::RemoveAttribute" ref="a22" args="(const std::string &amp;name)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a22">RemoveAttribute</a> (const std::string &amp;name)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">STL std::string form. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a23"></a><!-- doxytag: member="TiXmlElement::FirstAttribute" ref="a23" args="() const " -->
const <a class="el" href="classTiXmlAttribute.html">TiXmlAttribute</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a23">FirstAttribute</a> () const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Access the first attribute in this element. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a25"></a><!-- doxytag: member="TiXmlElement::LastAttribute" ref="a25" args="() const " -->
const <a class="el" href="classTiXmlAttribute.html">TiXmlAttribute</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a25">LastAttribute</a> () const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Access the last attribute in this element. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">const char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a27">GetText</a> () const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Convenience function for easy access to the text inside an element. <a href="#a27"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a28"></a><!-- doxytag: member="TiXmlElement::Clone" ref="a28" args="() const " -->
virtual <a class="el" href="classTiXmlNode.html">TiXmlNode</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a28">Clone</a> () const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Creates a new Element and returns it - the returned element is a copy. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTiXmlElement.html#a29">Print</a> (FILE *cfile, int depth) const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">All TinyXml classes can print themselves to a filestream. <a href="#a29"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
The element is a container class.
<p>
It has a value, the element name, and can contain other elements, text, comments, and unknowns. Elements also contain an arbitrary number of attributes.
<p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="a7"></a><!-- doxytag: member="TiXmlElement::Attribute" ref="a7" args="(const char *name, double *d) 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">const char* TiXmlElement::Attribute </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">const char *&nbsp;</td>
<td class="mdname" nowrap> <em>name</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>double *&nbsp;</td>
<td class="mdname" nowrap> <em>d</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"> const</td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Given an attribute name, <a class="el" href="classTiXmlElement.html#a5">Attribute()</a> returns the value for the attribute of that name, or null if none exists.
<p>
If the attribute exists and can be converted to an double, the double value will be put in the return 'd', if 'd' is non-null. </td>
</tr>
</table>
<a class="anchor" name="a6"></a><!-- doxytag: member="TiXmlElement::Attribute" ref="a6" args="(const char *name, int *i) 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">const char* TiXmlElement::Attribute </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">const char *&nbsp;</td>
<td class="mdname" nowrap> <em>name</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>int *&nbsp;</td>
<td class="mdname" nowrap> <em>i</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"> const</td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Given an attribute name, <a class="el" href="classTiXmlElement.html#a5">Attribute()</a> returns the value for the attribute of that name, or null if none exists.
<p>
If the attribute exists and can be converted to an integer, the integer value will be put in the return 'i', if 'i' is non-null. </td>
</tr>
</table>
<a class="anchor" name="a27"></a><!-- doxytag: member="TiXmlElement::GetText" ref="a27" 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">const char* TiXmlElement::GetText </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap> const</td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Convenience function for easy access to the text inside an element.
<p>
Although easy and concise, <a class="el" href="classTiXmlElement.html#a27">GetText()</a> is limited compared to getting the <a class="el" href="classTiXmlText.html">TiXmlText</a> child and accessing it directly.<p>
If the first child of 'this' is a <a class="el" href="classTiXmlText.html">TiXmlText</a>, the <a class="el" href="classTiXmlElement.html#a27">GetText()</a> returs the character string of the Text node, else null is returned.<p>
This is a convenient method for getting the text of simple contained text: <div class="fragment"><pre class="fragment"> &lt;foo&gt;This is text&lt;/foo&gt;
const char* str = fooElement-&gt;GetText();
</pre></div><p>
'str' will be a pointer to "This is text".<p>
Note that this function can be misleading. If the element foo was created from this XML: <div class="fragment"><pre class="fragment"> &lt;foo&gt;&lt;b&gt;This is text&lt;/b&gt;&lt;/foo&gt;
</pre></div><p>
then the value of str would be null. The first child node isn't a text node, it is another element. From this XML: <div class="fragment"><pre class="fragment"> &lt;foo&gt;This is &lt;b&gt;text&lt;/b&gt;&lt;/foo&gt;
</pre></div> <a class="el" href="classTiXmlElement.html#a27">GetText()</a> will return "This is ".<p>
WARNING: <a class="el" href="classTiXmlElement.html#a27">GetText()</a> accesses a child node - don't become confused with the similarly named <a class="el" href="classTiXmlHandle.html#a17">TiXmlHandle::Text()</a> and <a class="el" href="classTiXmlNode.html#a70">TiXmlNode::ToText()</a> which are safe type casts on the referenced node. </td>
</tr>
</table>
<a class="anchor" name="a29"></a><!-- doxytag: member="TiXmlElement::Print" ref="a29" args="(FILE *cfile, int depth) 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 void TiXmlElement::Print </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">FILE *&nbsp;</td>
<td class="mdname" nowrap> <em>cfile</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>int&nbsp;</td>
<td class="mdname" nowrap> <em>depth</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"> const<code> [virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
All TinyXml classes can print themselves to a filestream.
<p>
This is a formatted print, and will insert tabs and newlines.<p>
(For an unformatted stream, use the &lt;&lt; operator.)
<p>
Implements <a class="el" href="classTiXmlBase.html#a2">TiXmlBase</a>. </td>
</tr>
</table>
<a class="anchor" name="a8"></a><!-- doxytag: member="TiXmlElement::QueryIntAttribute" ref="a8" args="(const char *name, int *_value) 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 TiXmlElement::QueryIntAttribute </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">const char *&nbsp;</td>
<td class="mdname" nowrap> <em>name</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>int *&nbsp;</td>
<td class="mdname" nowrap> <em>_value</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"> const</td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
QueryIntAttribute examines the attribute - it is an alternative to the <a class="el" href="classTiXmlElement.html#a5">Attribute()</a> method with richer error checking.
<p>
If the attribute is an integer, it is stored in 'value' and the call returns TIXML_SUCCESS. If it is not an integer, it returns TIXML_WRONG_TYPE. If the attribute does not exist, then TIXML_NO_ATTRIBUTE is returned. </td>
</tr>
</table>
<a class="anchor" name="a19"></a><!-- doxytag: member="TiXmlElement::SetAttribute" ref="a19" args="(const char *name, int value)" --><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 TiXmlElement::SetAttribute </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">const char *&nbsp;</td>
<td class="mdname" nowrap> <em>name</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>int&nbsp;</td>
<td class="mdname" nowrap> <em>value</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Sets an attribute of name to a given value.
<p>
The attribute will be created if it does not exist, or changed if it does. </td>
</tr>
</table>
<a class="anchor" name="a11"></a><!-- doxytag: member="TiXmlElement::SetAttribute" ref="a11" args="(const char *name, const char *_value)" --><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 TiXmlElement::SetAttribute </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">const char *&nbsp;</td>
<td class="mdname" nowrap> <em>name</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>const char *&nbsp;</td>
<td class="mdname" nowrap> <em>_value</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Sets an attribute of name to a given value.
<p>
The attribute will be created if it does not exist, or changed if it does. </td>
</tr>
</table>
<a class="anchor" name="a20"></a><!-- doxytag: member="TiXmlElement::SetDoubleAttribute" ref="a20" args="(const char *name, double value)" --><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 TiXmlElement::SetDoubleAttribute </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">const char *&nbsp;</td>
<td class="mdname" nowrap> <em>name</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>double&nbsp;</td>
<td class="mdname" nowrap> <em>value</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Sets an attribute of name to a given value.
<p>
The attribute will be created if it does not exist, or changed if it does. </td>
</tr>
</table>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="tinyxml_8h-source.html">tinyxml.h</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Sat Oct 8 14:15:30 2005 for TinyXml by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.4 </small></address>
</body>
</html>