173 lines
34 KiB
HTML
173 lines
34 KiB
HTML
<!-- HTML header for doxygen 1.8.8-->
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<!-- For Mobile Devices -->
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta name="generator" content="Doxygen 1.8.12"/>
|
|
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
|
|
<title>exml: Ewol XML parser: Read an XML content</title>
|
|
<!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
|
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
|
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
|
|
<script type="text/javascript" src="doxy-boot.js"></script>
|
|
</head>
|
|
<body>
|
|
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
|
|
<div class="container">
|
|
<div class="navbar-header">
|
|
<a class="navbar-brand">exml: Ewol XML parser 0.7.0</a>
|
|
</div>
|
|
<div id="navbar" class="navbar-collapse collapse">
|
|
<ul class="nav navbar-nav">
|
|
<li><a href="index.html">Main Page</a></li>
|
|
<li><a href="pages.html">Related Pages</a></li>
|
|
<li><a href="namespaces.html">Namespaces</a></li>
|
|
<li><a href="annotated.html">Classes</a></li>
|
|
<li><a href="files.html">Files</a></li>
|
|
</ul>
|
|
<ul class="nav navbar-nav navbar-right">
|
|
<li class="dropdown">
|
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
|
|
Link-libs<span class="caret"></span>
|
|
</a>
|
|
<ul class="dropdown-menu">
|
|
<li><a href="http://HeeroYui.github.io/lutin">lutin</a></li>
|
|
<li><a href="http://atria-soft.github.io/ewol">ewol</a></li>
|
|
<li><a href="http://atria-soft.github.io/echrono">echrono</a></li>
|
|
<li><a href="http://atria-soft.github.io/etk">etk</a></li>
|
|
<li><a href="http://atria-soft.github.io/ejson">ejson</a></li>
|
|
<li><a href="http://atria-soft.github.io/exml">exml</a></li>
|
|
<li><a href="http://atria-soft.github.io/esvg">esvg</a></li>
|
|
<li><a href="http://atria-soft.github.io/egami">egami</a></li>
|
|
<li><a href="http://atria-soft.github.io/gale">gale</a></li>
|
|
<li><a href="http://atria-soft.github.io/ege">ege</a></li>
|
|
<li><a href="http://atria-soft.github.io/elog">elog</a></li>
|
|
<li><a href="http://atria-soft.github.io/ememory">ememory</a></li>
|
|
<li><a href="http://atria-soft.github.io/enet">enet</a></li>
|
|
<li><a href="http://atria-soft.github.io/eproperty">eproperty</a></li>
|
|
<li><a href="http://atria-soft.github.io/esignal">esignal</a></li>
|
|
<li><a href="http://atria-soft.github.io/etranslate">etranslate</a></li>
|
|
<li><a href="http://atria-soft.github.io/zeus">zeus</a></li>
|
|
<li><a href="http://musicdsp.github.io/audio-ess">audio-ess</a></li>
|
|
<li><a href="http://musicdsp.github.io/audio">audio</a></li>
|
|
<li><a href="http://musicdsp.github.io/audio-drain">audio-drain</a></li>
|
|
<li><a href="http://musicdsp.github.io/audio-orchestra">audio-orchestra</a></li>
|
|
<li><a href="http://musicdsp.github.io/audio-river">audio-river</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<div id="search-box" class="input-group">
|
|
<div class="input-group-btn">
|
|
<button aria-expanded="false" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
|
<span class="glyphicon glyphicon-search"></span>
|
|
<span class="caret"></span>
|
|
</button>
|
|
<ul class="dropdown-menu">
|
|
<li><a href="#">All</a></li>
|
|
<li><a href="#">Classes</a></li>
|
|
<li><a href="#">Namespaces</a></li>
|
|
<li><a href="#">Files</a></li>
|
|
<li><a href="#">Functions</a></li>
|
|
<li><a href="#">Variables</a></li>
|
|
<li><a href="#">Typedefs</a></li>
|
|
<li><a href="#">Enumerations</a></li>
|
|
<li><a href="#">Enumerator</a></li>
|
|
<li><a href="#">Friends</a></li>
|
|
<li><a href="#">Macros</a></li>
|
|
<li><a href="#">Pages</a></li>
|
|
</ul>
|
|
</div>
|
|
<button id="search-close" type="button" class="close" aria-label="Close">
|
|
<span aria-hidden="true"></span>
|
|
</button>
|
|
<input id="search-field" class="form-control" accesskey="S" onkeydown="searchBox.OnSearchFieldChange(event);" placeholder="Search ..." type="text">
|
|
</div>
|
|
</div><!--/.nav-collapse -->
|
|
</div>
|
|
</nav>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div class="content" id="content">
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-sm-12 panel panel-default" style="padding-bottom: 15px;">
|
|
<div style="margin-bottom: 15px;margin-top: 60px;">
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.12 -->
|
|
<script type="text/javascript">
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
$(function() {
|
|
initMenu('',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
</script>
|
|
<div id="main-nav"></div>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">Read an XML content </div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="toc"><h3>Table of Contents</h3>
|
|
<ul><li class="level1"><a href="#exml_tutorial_read_file">Read an XML file </a></li>
|
|
<li class="level1"><a href="#exml_tutorial_read_stream">Read an XML Stream </a></li>
|
|
<li class="level1"><a href="#exml_tutorial_read_folow">Access at all Element datas </a></li>
|
|
<li class="level1"><a href="#exml_tutorial_read_all">All example file </a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="textblock"><p>The first thing to do when reading or writing a XML file/stream, is to declare the Document interface</p>
|
|
<p>Include exml </p><div class="fragment"><div class="line"><span class="preprocessor">#include <<a class="code" href="exml_8hpp.html">exml/exml.hpp</a>></span></div></div><!-- fragment --><p> Declare document interface </p><div class="fragment"><div class="line"> <a class="code" href="classexml_1_1_document.html">exml::Document</a> doc;</div></div><!-- fragment --><h1><a class="anchor" id="exml_tutorial_read_file"></a>
|
|
Read an XML file </h1>
|
|
<p>File to read: "read.xml" </p><div class="fragment"><div class="line"><?<span class="keyword">xml</span> <span class="keyword">version</span>=<span class="stringliteral">"1.0"</span> <span class="keyword">encoding</span>=<span class="stringliteral">"UTF-8"</span> <span class="keyword">standalone</span>=<span class="stringliteral">"true"</span>?></div><div class="line"><span class="comment"><!-- my comment --></span></div><div class="line"><<span class="keywordtype">exml</span> <span class="keyword">attributeExample</span>=<span class="stringliteral">"my data attribute"</span>></div><div class="line"> <span class="keyword">coucou</span></div><div class="line"> <span class="comment"><!-- comment --></span></div><div class="line"> <<span class="keywordtype">subNodeA</span>/></div><div class="line"> <<span class="keywordtype">subNodeB</span>/></div><div class="line"></<span class="keywordtype">exml</span>></div></div><!-- fragment --><p>Reading a file is done like this: </p><div class="fragment"><div class="line"> <span class="keywordtype">bool</span> retParse = doc.<a class="code" href="classexml_1_1_document.html#a8cab856ba4904ddb422cb310216557ec">load</a>(<span class="stringliteral">"DATA:read.xml"</span>);</div></div><!-- fragment --><p> The file naming is manage by <a class="elRef" doxygen="/home/heero/dev/perso/out/doc/release/etk.tag:http://atria-soft.github.io/etk/" href="http://atria-soft.github.io/etk/classetk_1_1_f_s_node.html">etk::FSNode</a> that provide "DATA:" start string for internal application asset. You can use external path like "./plop/file.xml" too.</p>
|
|
<h1><a class="anchor" id="exml_tutorial_read_stream"></a>
|
|
Read an XML Stream </h1>
|
|
<p>Reading a stream is done like this: </p><div class="fragment"><div class="line"> std::string stream = <span class="stringliteral">"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"true\"?>"</span></div><div class="line"> <span class="stringliteral">"<!-- my comment -->"</span></div><div class="line"> <span class="stringliteral">"<exml attributeExample=\"my data attribute\">coucou</exml>"</span>;</div><div class="line"> <span class="keywordtype">bool</span> retParse = doc.<a class="code" href="classexml_1_1_document.html#abbc0c0135f96cc4a0b4730b9678af6a4">parse</a>(stream);</div></div><!-- fragment --><p> In C and C++ it is very hard to read string with the \" then to simplify parsing of xml the parser engine support the use of simple ' interface: </p><div class="fragment"><div class="line"> std::string stream = <span class="stringliteral">"<?xml version='1.0' encoding='UTF-8' standalone='true'?>"</span></div><div class="line"> <span class="stringliteral">"<!-- my comment -->"</span></div><div class="line"> <span class="stringliteral">"<exml attributeExample='my data attribute'>coucou</exml>"</span>;</div><div class="line"> <span class="keywordtype">bool</span> retParse = doc.<a class="code" href="classexml_1_1_document.html#abbc0c0135f96cc4a0b4730b9678af6a4">parse</a>(stream);</div></div><!-- fragment --><h1><a class="anchor" id="exml_tutorial_read_folow"></a>
|
|
Access at all Element datas </h1>
|
|
<p>In an <a class="el" href="classexml_1_1_element.html" title="Basic element Node of an XML document <YYYYY>. ">exml::Element</a> (or <a class="el" href="classexml_1_1_document.html" title="Basic document element of a document. ">exml::Document</a>) the sub-nodes are accessible threw an abstraction class stores in an element name <b>nodes</b></p>
|
|
<p>Get a node with its name: </p><div class="fragment"><div class="line"> <a class="code" href="classexml_1_1_element.html">exml::Element</a> <a class="code" href="namespaceexml.html#a49be10c1d94fea7f1fe579e5ec041e55a8e2dcfd7e7e24b1ca76c1193f645902b">element</a> = doc.<a class="code" href="classexml_1_1_element.html#acf09c48748366af9925513ed978db4c9">nodes</a>[<span class="stringliteral">"exml"</span>];</div></div><!-- fragment --><p> Reading all file nodes: </p><div class="fragment"><div class="line"> <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span> itElem: element.<a class="code" href="classexml_1_1_element.html#acf09c48748366af9925513ed978db4c9">nodes</a>) {</div><div class="line"> <span class="keywordflow">if</span> (itElem.isElement() == <span class="keyword">true</span>) {</div><div class="line"> <span class="comment">// get the <XXXX ... name</span></div><div class="line"> std::string value = itElem.toElement().getValue();</div><div class="line"> TEST_INFO(<span class="stringliteral">" '"</span> << value << <span class="stringliteral">"'"</span>);</div><div class="line"> } <span class="keywordflow">else</span> {</div><div class="line"> <span class="comment">// simple debug for other type:</span></div><div class="line"> TEST_INFO(<span class="stringliteral">" ** "</span> << itElem);</div><div class="line"> }</div><div class="line"> }</div></div><!-- fragment --><p> <b>note:</b> the itElem is a simple <a class="el" href="classexml_1_1_node.html" title="Basic main object of all xml elements. ">exml::Node</a> that can be all the xml type. you can change the type by calling: toDocument(), toElement(), toString() ...</p>
|
|
<p>In a C style mode: </p><div class="fragment"><div class="line"> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> iii=0; iii<element.<a class="code" href="classexml_1_1_element.html#acf09c48748366af9925513ed978db4c9">nodes</a>.<a class="code" href="classexml_1_1_element_data.html#a5716dadf951f90a0bd52204983c36e3b">size</a>(); ++iii) {</div><div class="line"> <span class="keyword">const</span> <a class="code" href="classexml_1_1_node.html">exml::Node</a> <a class="code" href="namespaceexml.html#a49be10c1d94fea7f1fe579e5ec041e55a36c4536996ca5615dcf9911f068786dc">node</a> = element.<a class="code" href="classexml_1_1_element.html#acf09c48748366af9925513ed978db4c9">nodes</a>[iii];</div><div class="line"> <span class="keywordflow">if</span> (node.<a class="code" href="classexml_1_1_node.html#a6fc2ab327f4add7030ff8d95d7f03d1b">isElement</a>() == <span class="keyword">true</span>) {</div><div class="line"> <span class="comment">// get the <XXXX ... name</span></div><div class="line"> std::string value = node.<a class="code" href="classexml_1_1_node.html#a767481c377a99616b66b953a02f64dbe">toElement</a>().<a class="code" href="classexml_1_1_node.html#a8b9a9d4befc43fce6cf11076b4d11aca">getValue</a>();</div><div class="line"> TEST_INFO(<span class="stringliteral">" '"</span> << value << <span class="stringliteral">"'"</span>);</div><div class="line"> } <span class="keywordflow">else</span> {</div><div class="line"> <span class="comment">// simple debug for other type:</span></div><div class="line"> TEST_INFO(<span class="stringliteral">" ** "</span> << node);</div><div class="line"> }</div><div class="line"> }</div></div><!-- fragment --><p>In an <a class="el" href="classexml_1_1_element.html" title="Basic element Node of an XML document <YYYYY>. ">exml::Element</a> (or <a class="el" href="classexml_1_1_document.html" title="Basic document element of a document. ">exml::Document</a> or <a class="el" href="classexml_1_1_declaration.html" title="Declaration node: <?XXXXXX ... >. ">exml::Declaration</a>) the sub-nodes are accessible threw an abstraction class stores in an element name <b>attributes</b></p>
|
|
<p>Reading all Attributes of one node: </p><div class="fragment"><div class="line"> <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span> itElem: element.<a class="code" href="classexml_1_1_attribute_list.html#ae5ecfeb8362dc2dd0481ec74e56f19dd">attributes</a>) {</div><div class="line"> std::string value = itElem.getValue();</div><div class="line"> TEST_INFO(<span class="stringliteral">" '"</span> << value << <span class="stringliteral">"'"</span>);</div><div class="line"> }</div><div class="line"> TEST_INFO(<span class="stringliteral">" list of attribute in C:"</span>);</div></div><!-- fragment --><p> In a C style mode: </p><div class="fragment"><div class="line"> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> iii=0; iii<element.<a class="code" href="classexml_1_1_attribute_list.html#ae5ecfeb8362dc2dd0481ec74e56f19dd">attributes</a>.<a class="code" href="classexml_1_1_attribute_list_data.html#a734f248937ebea5278ef7ff4d278c729">size</a>(); ++iii) {</div><div class="line"> <span class="keyword">const</span> <a class="code" href="classexml_1_1_attribute.html">exml::Attribute</a> attr = element.<a class="code" href="classexml_1_1_attribute_list.html#ae5ecfeb8362dc2dd0481ec74e56f19dd">attributes</a>[iii];</div><div class="line"> std::string value = attr.<a class="code" href="classexml_1_1_node.html#a8b9a9d4befc43fce6cf11076b4d11aca">getValue</a>();</div><div class="line"> TEST_INFO(<span class="stringliteral">" '"</span> << value << <span class="stringliteral">"'"</span>);</div><div class="line"> }</div></div><!-- fragment --><p> Get an attribute data: </p><div class="fragment"><div class="line"> std::string attributeValue = element.<a class="code" href="classexml_1_1_attribute_list.html#ae5ecfeb8362dc2dd0481ec74e56f19dd">attributes</a>[<span class="stringliteral">"attributeExample"</span>];</div><div class="line"> TEST_INFO(<span class="stringliteral">" direct get: '"</span> << attributeValue << <span class="stringliteral">"'"</span>);</div></div><!-- fragment --><p>In an <a class="el" href="classexml_1_1_element.html" title="Basic element Node of an XML document <YYYYY>. ">exml::Element</a> (or <a class="el" href="classexml_1_1_document.html" title="Basic document element of a document. ">exml::Document</a>) the internal data text can be accessible threw the interface:</p>
|
|
<p>Get all the data in an element in text mode: </p><div class="fragment"><div class="line"> std::string internalData = element.<a class="code" href="classexml_1_1_element.html#ad2393088d96dd135ba899e8c49c4031a">getText</a>();</div></div><!-- fragment --><h1><a class="anchor" id="exml_tutorial_read_all"></a>
|
|
All example file </h1>
|
|
<div class="fragment"><div class="line"></div><div class="line"><span class="preprocessor">#include <test-debug/debug.hpp></span></div><div class="line"><span class="preprocessor">#include <<a class="code" href="exml_8hpp.html">exml/exml.hpp</a>></span></div><div class="line"><span class="preprocessor">#include "read.hpp"</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> readFromFile() {</div><div class="line"> <a class="code" href="classexml_1_1_document.html">exml::Document</a> doc;</div><div class="line"> <span class="keywordtype">bool</span> retParse = doc.<a class="code" href="classexml_1_1_document.html#a8cab856ba4904ddb422cb310216557ec">load</a>(<span class="stringliteral">"DATA:read.xml"</span>);</div><div class="line"> TEST_INFO(<span class="stringliteral">"parse ret = "</span> << retParse);</div><div class="line"> TEST_INFO(<span class="stringliteral">"Debug display of the tree:"</span>);</div><div class="line"> doc.<a class="code" href="classexml_1_1_document.html#a2257dc9efd8074f8a0d38f73725337d9">display</a>();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> readFromString1() {</div><div class="line"> <a class="code" href="classexml_1_1_document.html">exml::Document</a> doc;</div><div class="line"> TEST_INFO(<span class="stringliteral">"parse"</span>);</div><div class="line"> std::string stream = <span class="stringliteral">"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"true\"?>"</span></div><div class="line"> <span class="stringliteral">"<!-- my comment -->"</span></div><div class="line"> <span class="stringliteral">"<exml attributeExample=\"my data attribute\">coucou</exml>"</span>;</div><div class="line"> <span class="keywordtype">bool</span> retParse = doc.<a class="code" href="classexml_1_1_document.html#abbc0c0135f96cc4a0b4730b9678af6a4">parse</a>(stream);</div><div class="line"> TEST_INFO(<span class="stringliteral">"parse ret = "</span> << retParse);</div><div class="line"> TEST_INFO(<span class="stringliteral">"Debug display of the tree:"</span>);</div><div class="line"> doc.<a class="code" href="classexml_1_1_document.html#a2257dc9efd8074f8a0d38f73725337d9">display</a>();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> readFromString2() {</div><div class="line"> <a class="code" href="classexml_1_1_document.html">exml::Document</a> doc;</div><div class="line"> TEST_INFO(<span class="stringliteral">"parse"</span>);</div><div class="line"> std::string stream = <span class="stringliteral">"<?xml version='1.0' encoding='UTF-8' standalone='true'?>"</span></div><div class="line"> <span class="stringliteral">"<!-- my comment -->"</span></div><div class="line"> <span class="stringliteral">"<exml attributeExample='my data attribute'>coucou</exml>"</span>;</div><div class="line"> <span class="keywordtype">bool</span> retParse = doc.<a class="code" href="classexml_1_1_document.html#abbc0c0135f96cc4a0b4730b9678af6a4">parse</a>(stream);</div><div class="line"> TEST_INFO(<span class="stringliteral">"parse ret = "</span> << retParse);</div><div class="line"> TEST_INFO(<span class="stringliteral">"Debug display of the tree:"</span>);</div><div class="line"> doc.<a class="code" href="classexml_1_1_document.html#a2257dc9efd8074f8a0d38f73725337d9">display</a>();</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> readFull() {</div><div class="line"> <a class="code" href="classexml_1_1_document.html">exml::Document</a> doc;</div><div class="line"> TEST_INFO(<span class="stringliteral">"parse"</span>);</div><div class="line"> <span class="keywordtype">bool</span> retParse = doc.<a class="code" href="classexml_1_1_document.html#a8cab856ba4904ddb422cb310216557ec">load</a>(<span class="stringliteral">"DATA:read.xml"</span>);</div><div class="line"> TEST_INFO(<span class="stringliteral">"parse ret = "</span> << retParse);</div><div class="line"> TEST_INFO(<span class="stringliteral">"Debug display of the tree:"</span>);</div><div class="line"> doc.<a class="code" href="classexml_1_1_document.html#a2257dc9efd8074f8a0d38f73725337d9">display</a>();</div><div class="line"> TEST_INFO(<span class="stringliteral">"list of attribute:"</span>);</div><div class="line"> <span class="keywordflow">for</span> (<span class="keyword">auto</span> it: doc.<a class="code" href="classexml_1_1_attribute_list.html#ae5ecfeb8362dc2dd0481ec74e56f19dd">attributes</a>) {</div><div class="line"> TEST_INFO(<span class="stringliteral">" "</span> << it);</div><div class="line"> }</div><div class="line"> TEST_INFO(<span class="stringliteral">"list of sub-node:"</span>);</div><div class="line"> <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span> it: doc.<a class="code" href="classexml_1_1_element.html#acf09c48748366af9925513ed978db4c9">nodes</a>) {</div><div class="line"> TEST_INFO(<span class="stringliteral">" "</span> << it);</div><div class="line"> <span class="keywordflow">if</span> (it.isElement() == <span class="keyword">false</span>) {</div><div class="line"> <span class="keywordflow">continue</span>;</div><div class="line"> }</div><div class="line"> <a class="code" href="classexml_1_1_element.html">exml::Element</a> elem = it.<a class="code" href="classexml_1_1_node.html#a767481c377a99616b66b953a02f64dbe">toElement</a>();</div><div class="line"> <span class="keywordflow">if</span> (elem.<a class="code" href="classexml_1_1_node.html#ae2be1ded472149113f3ea70710f57b39">exist</a>() == <span class="keyword">false</span>) {</div><div class="line"> <span class="keywordflow">continue</span>;</div><div class="line"> }</div><div class="line"> TEST_INFO(<span class="stringliteral">" list of attribute:"</span>);</div><div class="line"> <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span> itElem: elem.<a class="code" href="classexml_1_1_attribute_list.html#ae5ecfeb8362dc2dd0481ec74e56f19dd">attributes</a>) {</div><div class="line"> TEST_INFO(<span class="stringliteral">" "</span> << itElem);</div><div class="line"> }</div><div class="line"> TEST_INFO(<span class="stringliteral">" list of sub-node:"</span>);</div><div class="line"> <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span> itElem: elem.<a class="code" href="classexml_1_1_element.html#acf09c48748366af9925513ed978db4c9">nodes</a>) {</div><div class="line"> TEST_INFO(<span class="stringliteral">" "</span> << itElem);</div><div class="line"> }</div><div class="line"> }</div><div class="line"> TEST_INFO(<span class="stringliteral">" Direct get node exml:"</span>);</div><div class="line"> <a class="code" href="classexml_1_1_element.html">exml::Element</a> element = doc.<a class="code" href="classexml_1_1_element.html#acf09c48748366af9925513ed978db4c9">nodes</a>[<span class="stringliteral">"exml"</span>];</div><div class="line"> TEST_INFO(<span class="stringliteral">" list of attribute:"</span>);</div><div class="line"> <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span> itElem: element.<a class="code" href="classexml_1_1_attribute_list.html#ae5ecfeb8362dc2dd0481ec74e56f19dd">attributes</a>) {</div><div class="line"> std::string value = itElem.getValue();</div><div class="line"> TEST_INFO(<span class="stringliteral">" '"</span> << value << <span class="stringliteral">"'"</span>);</div><div class="line"> }</div><div class="line"> TEST_INFO(<span class="stringliteral">" list of attribute in C:"</span>);</div><div class="line"> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> iii=0; iii<element.<a class="code" href="classexml_1_1_attribute_list.html#ae5ecfeb8362dc2dd0481ec74e56f19dd">attributes</a>.<a class="code" href="classexml_1_1_attribute_list_data.html#a734f248937ebea5278ef7ff4d278c729">size</a>(); ++iii) {</div><div class="line"> <span class="keyword">const</span> <a class="code" href="classexml_1_1_attribute.html">exml::Attribute</a> attr = element.<a class="code" href="classexml_1_1_attribute_list.html#ae5ecfeb8362dc2dd0481ec74e56f19dd">attributes</a>[iii];</div><div class="line"> std::string value = attr.<a class="code" href="classexml_1_1_node.html#a8b9a9d4befc43fce6cf11076b4d11aca">getValue</a>();</div><div class="line"> TEST_INFO(<span class="stringliteral">" '"</span> << value << <span class="stringliteral">"'"</span>);</div><div class="line"> }</div><div class="line"> std::string attributeValue = element.<a class="code" href="classexml_1_1_attribute_list.html#ae5ecfeb8362dc2dd0481ec74e56f19dd">attributes</a>[<span class="stringliteral">"attributeExample"</span>];</div><div class="line"> TEST_INFO(<span class="stringliteral">" direct get: '"</span> << attributeValue << <span class="stringliteral">"'"</span>);</div><div class="line"> TEST_INFO(<span class="stringliteral">" list of sub-node:"</span>);</div><div class="line"> <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span> itElem: element.<a class="code" href="classexml_1_1_element.html#acf09c48748366af9925513ed978db4c9">nodes</a>) {</div><div class="line"> <span class="keywordflow">if</span> (itElem.isElement() == <span class="keyword">true</span>) {</div><div class="line"> <span class="comment">// get the <XXXX ... name</span></div><div class="line"> std::string value = itElem.toElement().getValue();</div><div class="line"> TEST_INFO(<span class="stringliteral">" '"</span> << value << <span class="stringliteral">"'"</span>);</div><div class="line"> } <span class="keywordflow">else</span> {</div><div class="line"> <span class="comment">// simple debug for other type:</span></div><div class="line"> TEST_INFO(<span class="stringliteral">" ** "</span> << itElem);</div><div class="line"> }</div><div class="line"> }</div><div class="line"> TEST_INFO(<span class="stringliteral">" list of sub-node in C:"</span>);</div><div class="line"> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> iii=0; iii<element.<a class="code" href="classexml_1_1_element.html#acf09c48748366af9925513ed978db4c9">nodes</a>.<a class="code" href="classexml_1_1_element_data.html#a5716dadf951f90a0bd52204983c36e3b">size</a>(); ++iii) {</div><div class="line"> <span class="keyword">const</span> <a class="code" href="classexml_1_1_node.html">exml::Node</a> node = element.<a class="code" href="classexml_1_1_element.html#acf09c48748366af9925513ed978db4c9">nodes</a>[iii];</div><div class="line"> <span class="keywordflow">if</span> (node.<a class="code" href="classexml_1_1_node.html#a6fc2ab327f4add7030ff8d95d7f03d1b">isElement</a>() == <span class="keyword">true</span>) {</div><div class="line"> <span class="comment">// get the <XXXX ... name</span></div><div class="line"> std::string value = node.<a class="code" href="classexml_1_1_node.html#a767481c377a99616b66b953a02f64dbe">toElement</a>().<a class="code" href="classexml_1_1_node.html#a8b9a9d4befc43fce6cf11076b4d11aca">getValue</a>();</div><div class="line"> TEST_INFO(<span class="stringliteral">" '"</span> << value << <span class="stringliteral">"'"</span>);</div><div class="line"> } <span class="keywordflow">else</span> {</div><div class="line"> <span class="comment">// simple debug for other type:</span></div><div class="line"> TEST_INFO(<span class="stringliteral">" ** "</span> << node);</div><div class="line"> }</div><div class="line"> }</div><div class="line"> std::string internalData = element.<a class="code" href="classexml_1_1_element.html#ad2393088d96dd135ba899e8c49c4031a">getText</a>();</div><div class="line"> </div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> appl::read() {</div><div class="line"> readFromFile();</div><div class="line"> readFromString1();</div><div class="line"> readFromString1();</div><div class="line"> readFull();</div><div class="line">}</div></div><!-- fragment --> </div></div><!-- contents -->
|
|
<!-- HTML footer for doxygen 1.8.8-->
|
|
<!-- start footer part -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated on Mon Oct 24 2016 15:35:49 for exml: Ewol XML parser by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.12
|
|
</small></address>
|
|
</body>
|
|
</html>
|