• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5<meta http-equiv="X-UA-Compatible" content="IE=9"/>
6<meta name="generator" content="Doxygen 1.8.13"/>
7<meta name="viewport" content="width=device-width, initial-scale=1"/>
8<title>TinyXML-2: tinyxml2::XMLHandle Class Reference</title>
9<link href="tabs.css" rel="stylesheet" type="text/css"/>
10<script type="text/javascript" src="jquery.js"></script>
11<script type="text/javascript" src="dynsections.js"></script>
12<link href="search/search.css" rel="stylesheet" type="text/css"/>
13<script type="text/javascript" src="search/searchdata.js"></script>
14<script type="text/javascript" src="search/search.js"></script>
15<link href="doxygen.css" rel="stylesheet" type="text/css" />
16</head>
17<body>
18<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
19<div id="titlearea">
20<table cellspacing="0" cellpadding="0">
21 <tbody>
22 <tr style="height: 56px;">
23  <td id="projectalign" style="padding-left: 0.5em;">
24   <div id="projectname">TinyXML-2
25   &#160;<span id="projectnumber">7.0.0</span>
26   </div>
27  </td>
28 </tr>
29 </tbody>
30</table>
31</div>
32<!-- end header part -->
33<!-- Generated by Doxygen 1.8.13 -->
34<script type="text/javascript">
35var searchBox = new SearchBox("searchBox", "search",false,'Search');
36</script>
37<script type="text/javascript" src="menudata.js"></script>
38<script type="text/javascript" src="menu.js"></script>
39<script type="text/javascript">
40$(function() {
41  initMenu('',true,false,'search.php','Search');
42  $(document).ready(function() { init_search(); });
43});
44</script>
45<div id="main-nav"></div>
46<!-- window showing the filter options -->
47<div id="MSearchSelectWindow"
48     onmouseover="return searchBox.OnSearchSelectShow()"
49     onmouseout="return searchBox.OnSearchSelectHide()"
50     onkeydown="return searchBox.OnSearchSelectKey(event)">
51</div>
52
53<!-- iframe showing the search results (closed by default) -->
54<div id="MSearchResultsWindow">
55<iframe src="javascript:void(0)" frameborder="0"
56        name="MSearchResults" id="MSearchResults">
57</iframe>
58</div>
59
60<div id="nav-path" class="navpath">
61  <ul>
62<li class="navelem"><b>tinyxml2</b></li><li class="navelem"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a></li>  </ul>
63</div>
64</div><!-- top -->
65<div class="header">
66  <div class="summary">
67<a href="#pub-methods">Public Member Functions</a> &#124;
68<a href="classtinyxml2_1_1_x_m_l_handle-members.html">List of all members</a>  </div>
69  <div class="headertitle">
70<div class="title">tinyxml2::XMLHandle Class Reference</div>  </div>
71</div><!--header-->
72<div class="contents">
73
74<p><code>#include &lt;<a class="el" href="tinyxml2_8h_source.html">tinyxml2.h</a>&gt;</code></p>
75<table class="memberdecls">
76<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
77Public Member Functions</h2></td></tr>
78<tr class="memitem:a9c240a35c18f053509b4b97ddccd9793"><td class="memItemLeft" align="right" valign="top"><a id="a9c240a35c18f053509b4b97ddccd9793"></a>
79&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#a9c240a35c18f053509b4b97ddccd9793">XMLHandle</a> (<a class="el" href="classtinyxml2_1_1_x_m_l_node.html">XMLNode</a> *node)</td></tr>
80<tr class="memdesc:a9c240a35c18f053509b4b97ddccd9793"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a handle from any node (at any depth of the tree.) This can be a null pointer. <br /></td></tr>
81<tr class="separator:a9c240a35c18f053509b4b97ddccd9793"><td class="memSeparator" colspan="2">&#160;</td></tr>
82<tr class="memitem:aa2edbc1c0d3e3e8259bd98de7f1cf500"><td class="memItemLeft" align="right" valign="top"><a id="aa2edbc1c0d3e3e8259bd98de7f1cf500"></a>
83&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#aa2edbc1c0d3e3e8259bd98de7f1cf500">XMLHandle</a> (<a class="el" href="classtinyxml2_1_1_x_m_l_node.html">XMLNode</a> &amp;node)</td></tr>
84<tr class="memdesc:aa2edbc1c0d3e3e8259bd98de7f1cf500"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a handle from a node. <br /></td></tr>
85<tr class="separator:aa2edbc1c0d3e3e8259bd98de7f1cf500"><td class="memSeparator" colspan="2">&#160;</td></tr>
86<tr class="memitem:afd8e01e6018c07347b8e6d80272466aa"><td class="memItemLeft" align="right" valign="top"><a id="afd8e01e6018c07347b8e6d80272466aa"></a>
87&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#afd8e01e6018c07347b8e6d80272466aa">XMLHandle</a> (const <a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a> &amp;ref)</td></tr>
88<tr class="memdesc:afd8e01e6018c07347b8e6d80272466aa"><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy constructor. <br /></td></tr>
89<tr class="separator:afd8e01e6018c07347b8e6d80272466aa"><td class="memSeparator" colspan="2">&#160;</td></tr>
90<tr class="memitem:a75b908322bb4b83be3281b6845252b20"><td class="memItemLeft" align="right" valign="top"><a id="a75b908322bb4b83be3281b6845252b20"></a>
91<a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#a75b908322bb4b83be3281b6845252b20">operator=</a> (const <a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a> &amp;ref)</td></tr>
92<tr class="memdesc:a75b908322bb4b83be3281b6845252b20"><td class="mdescLeft">&#160;</td><td class="mdescRight">Assignment. <br /></td></tr>
93<tr class="separator:a75b908322bb4b83be3281b6845252b20"><td class="memSeparator" colspan="2">&#160;</td></tr>
94<tr class="memitem:a536447dc7f54c0cd11e031dad94795ae"><td class="memItemLeft" align="right" valign="top"><a id="a536447dc7f54c0cd11e031dad94795ae"></a>
95<a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#a536447dc7f54c0cd11e031dad94795ae">FirstChild</a> ()</td></tr>
96<tr class="memdesc:a536447dc7f54c0cd11e031dad94795ae"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the first child of this handle. <br /></td></tr>
97<tr class="separator:a536447dc7f54c0cd11e031dad94795ae"><td class="memSeparator" colspan="2">&#160;</td></tr>
98<tr class="memitem:a74b04dd0f15e0bf01860e282b840b6a3"><td class="memItemLeft" align="right" valign="top"><a id="a74b04dd0f15e0bf01860e282b840b6a3"></a>
99<a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#a74b04dd0f15e0bf01860e282b840b6a3">FirstChildElement</a> (const char *name=0)</td></tr>
100<tr class="memdesc:a74b04dd0f15e0bf01860e282b840b6a3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the first child element of this handle. <br /></td></tr>
101<tr class="separator:a74b04dd0f15e0bf01860e282b840b6a3"><td class="memSeparator" colspan="2">&#160;</td></tr>
102<tr class="memitem:a9d09f04435f0f2f7d0816b0198d0517b"><td class="memItemLeft" align="right" valign="top"><a id="a9d09f04435f0f2f7d0816b0198d0517b"></a>
103<a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#a9d09f04435f0f2f7d0816b0198d0517b">LastChild</a> ()</td></tr>
104<tr class="memdesc:a9d09f04435f0f2f7d0816b0198d0517b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the last child of this handle. <br /></td></tr>
105<tr class="separator:a9d09f04435f0f2f7d0816b0198d0517b"><td class="memSeparator" colspan="2">&#160;</td></tr>
106<tr class="memitem:a42cccd0ce8b1ce704f431025e9f19e0c"><td class="memItemLeft" align="right" valign="top"><a id="a42cccd0ce8b1ce704f431025e9f19e0c"></a>
107<a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#a42cccd0ce8b1ce704f431025e9f19e0c">LastChildElement</a> (const char *name=0)</td></tr>
108<tr class="memdesc:a42cccd0ce8b1ce704f431025e9f19e0c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the last child element of this handle. <br /></td></tr>
109<tr class="separator:a42cccd0ce8b1ce704f431025e9f19e0c"><td class="memSeparator" colspan="2">&#160;</td></tr>
110<tr class="memitem:a428374e756f4db4cbc287fec64eae02c"><td class="memItemLeft" align="right" valign="top"><a id="a428374e756f4db4cbc287fec64eae02c"></a>
111<a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#a428374e756f4db4cbc287fec64eae02c">PreviousSibling</a> ()</td></tr>
112<tr class="memdesc:a428374e756f4db4cbc287fec64eae02c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the previous sibling of this handle. <br /></td></tr>
113<tr class="separator:a428374e756f4db4cbc287fec64eae02c"><td class="memSeparator" colspan="2">&#160;</td></tr>
114<tr class="memitem:a786957e498039554ed334cdc36612a7e"><td class="memItemLeft" align="right" valign="top"><a id="a786957e498039554ed334cdc36612a7e"></a>
115<a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#a786957e498039554ed334cdc36612a7e">PreviousSiblingElement</a> (const char *name=0)</td></tr>
116<tr class="memdesc:a786957e498039554ed334cdc36612a7e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the previous sibling element of this handle. <br /></td></tr>
117<tr class="separator:a786957e498039554ed334cdc36612a7e"><td class="memSeparator" colspan="2">&#160;</td></tr>
118<tr class="memitem:aad2eccc7c7c7b18145877c978c3850b5"><td class="memItemLeft" align="right" valign="top"><a id="aad2eccc7c7c7b18145877c978c3850b5"></a>
119<a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#aad2eccc7c7c7b18145877c978c3850b5">NextSibling</a> ()</td></tr>
120<tr class="memdesc:aad2eccc7c7c7b18145877c978c3850b5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the next sibling of this handle. <br /></td></tr>
121<tr class="separator:aad2eccc7c7c7b18145877c978c3850b5"><td class="memSeparator" colspan="2">&#160;</td></tr>
122<tr class="memitem:ae41d88ee061f3c49a081630ff753b2c5"><td class="memItemLeft" align="right" valign="top"><a id="ae41d88ee061f3c49a081630ff753b2c5"></a>
123<a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#ae41d88ee061f3c49a081630ff753b2c5">NextSiblingElement</a> (const char *name=0)</td></tr>
124<tr class="memdesc:ae41d88ee061f3c49a081630ff753b2c5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the next sibling element of this handle. <br /></td></tr>
125<tr class="separator:ae41d88ee061f3c49a081630ff753b2c5"><td class="memSeparator" colspan="2">&#160;</td></tr>
126<tr class="memitem:a03ea6ec970a021b71bf1219a0f6717df"><td class="memItemLeft" align="right" valign="top"><a id="a03ea6ec970a021b71bf1219a0f6717df"></a>
127<a class="el" href="classtinyxml2_1_1_x_m_l_node.html">XMLNode</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#a03ea6ec970a021b71bf1219a0f6717df">ToNode</a> ()</td></tr>
128<tr class="memdesc:a03ea6ec970a021b71bf1219a0f6717df"><td class="mdescLeft">&#160;</td><td class="mdescRight">Safe cast to <a class="el" href="classtinyxml2_1_1_x_m_l_node.html">XMLNode</a>. This can return null. <br /></td></tr>
129<tr class="separator:a03ea6ec970a021b71bf1219a0f6717df"><td class="memSeparator" colspan="2">&#160;</td></tr>
130<tr class="memitem:a5e73ed8f3f6f9619d5a8bb1862c47d99"><td class="memItemLeft" align="right" valign="top"><a id="a5e73ed8f3f6f9619d5a8bb1862c47d99"></a>
131<a class="el" href="classtinyxml2_1_1_x_m_l_element.html">XMLElement</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#a5e73ed8f3f6f9619d5a8bb1862c47d99">ToElement</a> ()</td></tr>
132<tr class="memdesc:a5e73ed8f3f6f9619d5a8bb1862c47d99"><td class="mdescLeft">&#160;</td><td class="mdescRight">Safe cast to <a class="el" href="classtinyxml2_1_1_x_m_l_element.html">XMLElement</a>. This can return null. <br /></td></tr>
133<tr class="separator:a5e73ed8f3f6f9619d5a8bb1862c47d99"><td class="memSeparator" colspan="2">&#160;</td></tr>
134<tr class="memitem:a6ab9e8cbfb41417246e5657e3842c62a"><td class="memItemLeft" align="right" valign="top"><a id="a6ab9e8cbfb41417246e5657e3842c62a"></a>
135<a class="el" href="classtinyxml2_1_1_x_m_l_text.html">XMLText</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#a6ab9e8cbfb41417246e5657e3842c62a">ToText</a> ()</td></tr>
136<tr class="memdesc:a6ab9e8cbfb41417246e5657e3842c62a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Safe cast to <a class="el" href="classtinyxml2_1_1_x_m_l_text.html">XMLText</a>. This can return null. <br /></td></tr>
137<tr class="separator:a6ab9e8cbfb41417246e5657e3842c62a"><td class="memSeparator" colspan="2">&#160;</td></tr>
138<tr class="memitem:aa387368a1ad8d843a9f12df863d298de"><td class="memItemLeft" align="right" valign="top"><a id="aa387368a1ad8d843a9f12df863d298de"></a>
139<a class="el" href="classtinyxml2_1_1_x_m_l_unknown.html">XMLUnknown</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#aa387368a1ad8d843a9f12df863d298de">ToUnknown</a> ()</td></tr>
140<tr class="memdesc:aa387368a1ad8d843a9f12df863d298de"><td class="mdescLeft">&#160;</td><td class="mdescRight">Safe cast to <a class="el" href="classtinyxml2_1_1_x_m_l_unknown.html">XMLUnknown</a>. This can return null. <br /></td></tr>
141<tr class="separator:aa387368a1ad8d843a9f12df863d298de"><td class="memSeparator" colspan="2">&#160;</td></tr>
142<tr class="memitem:a108858be7ee3eb53f73b5194c1aa8ff0"><td class="memItemLeft" align="right" valign="top"><a id="a108858be7ee3eb53f73b5194c1aa8ff0"></a>
143<a class="el" href="classtinyxml2_1_1_x_m_l_declaration.html">XMLDeclaration</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtinyxml2_1_1_x_m_l_handle.html#a108858be7ee3eb53f73b5194c1aa8ff0">ToDeclaration</a> ()</td></tr>
144<tr class="memdesc:a108858be7ee3eb53f73b5194c1aa8ff0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Safe cast to <a class="el" href="classtinyxml2_1_1_x_m_l_declaration.html">XMLDeclaration</a>. This can return null. <br /></td></tr>
145<tr class="separator:a108858be7ee3eb53f73b5194c1aa8ff0"><td class="memSeparator" colspan="2">&#160;</td></tr>
146</table>
147<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
148<div class="textblock"><p>A <a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a> is a class that wraps a node pointer with null checks; this is an incredibly useful thing. Note that <a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a> is not part of the TinyXML-2 DOM structure. It is a separate utility class.</p>
149<p>Take an example: </p><pre class="fragment">&lt;Document&gt;
150    &lt;Element attributeA = "valueA"&gt;
151        &lt;Child attributeB = "value1" /&gt;
152        &lt;Child attributeB = "value2" /&gt;
153    &lt;/Element&gt;
154&lt;/Document&gt;
155</pre><p>Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very easy to write a <em>lot</em> of code that looks like:</p>
156<pre class="fragment">XMLElement* root = document.FirstChildElement( "Document" );
157if ( root )
158{
159    XMLElement* element = root-&gt;FirstChildElement( "Element" );
160    if ( element )
161    {
162        XMLElement* child = element-&gt;FirstChildElement( "Child" );
163        if ( child )
164        {
165            XMLElement* child2 = child-&gt;NextSiblingElement( "Child" );
166            if ( child2 )
167            {
168                // Finally do something useful.
169</pre><p>And that doesn't even cover "else" cases. <a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a> addresses the verbosity of such code. A <a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a> checks for null pointers so it is perfectly safe and correct to use:</p>
170<pre class="fragment">XMLHandle docHandle( &amp;document );
171XMLElement* child2 = docHandle.FirstChildElement( "Document" ).FirstChildElement( "Element" ).FirstChildElement().NextSiblingElement();
172if ( child2 )
173{
174    // do something useful
175</pre><p>Which is MUCH more concise and useful.</p>
176<p>It is also safe to copy handles - internally they are nothing more than node pointers. </p><pre class="fragment">XMLHandle handleCopy = handle;
177</pre><p>See also <a class="el" href="classtinyxml2_1_1_x_m_l_const_handle.html">XMLConstHandle</a>, which is the same as <a class="el" href="classtinyxml2_1_1_x_m_l_handle.html">XMLHandle</a>, but operates on const objects. </p>
178</div><hr/>The documentation for this class was generated from the following file:<ul>
179<li><a class="el" href="tinyxml2_8h_source.html">tinyxml2.h</a></li>
180</ul>
181</div><!-- contents -->
182<!-- start footer part -->
183<hr class="footer"/><address class="footer"><small>
184Generated on Tue Nov 6 2018 09:38:26 for TinyXML-2 by &#160;<a href="http://www.doxygen.org/index.html">
185<img class="footer" src="doxygen.png" alt="doxygen"/>
186</a> 1.8.13
187</small></address>
188</body>
189</html>
190