<!-- iframe showing the search results (closed by default) -->
<divid="MSearchResultsWindow">
<iframesrc="javascript:void(0)"frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
</div><!-- top -->
<divclass="header">
<divclass="headertitle">
<divclass="title">Read attributes and text information. </div></div>
</div><!--header-->
<divclass="contents">
<divclass="textblock"><p>There are fundamentally 2 ways of writing a key-value pair into an XML file. (Something that's always annoyed me about XML.) Either by using attributes, or by writing the key name into an element and the value into the text node wrapped by the element. Both approaches are illustrated in this example, which shows two ways to encode the value "2" into the key "v":</p>
<p><divclass="fragment"><divclass="line"><spanclass="keywordtype">bool</span> example_4()</div><divclass="line">{</div><divclass="line"><spanclass="keyword">static</span><spanclass="keyword">const</span><spanclass="keywordtype">char</span>* xml =</div><divclass="line"><spanclass="stringliteral">"<information>"</span></div><divclass="line"><spanclass="stringliteral">"<attributeApproach v='2' />"</span></div><divclass="line"><spanclass="stringliteral">"<textApproach>"</span></div><divclass="line"><spanclass="stringliteral">"<v>2</v>"</span></div><divclass="line"><spanclass="stringliteral">"</textApproach>"</span></div><divclass="line"><spanclass="stringliteral">"</information>"</span>;</div></div><!-- fragment --></p>
<p>TinyXML-2 has accessors for both approaches.</p>
<p>When using an attribute, you navigate to the XMLElement with that attribute and use the QueryIntAttribute() group of methods. (Also QueryFloatAttribute(), etc.)</p>
<p>When using the text approach, you need to navigate down one more step to the XMLElement that contains the text. Note the extra FirstChildElement( "v" ) in the code below. The value of the text can then be safely queried with the QueryIntText() group of methods. (Also QueryFloatText(), etc.)</p>