/** @file * @author Edouard DUPIN * @copyright 2016, Edouard DUPIN, all right reserved * @license MPL v2.0 (see license file) */ //! [exml_sample_read_all] #include //! [exml_sample_include] #include //! [exml_sample_include] #include "read.hpp" static void readFromFile() { //! [exml_sample_declare_doc] exml::Document doc; //! [exml_sample_declare_doc] //! [exml_sample_read_file] bool retParse = doc.load(etk::Uri("DATA:///read.xml")); //! [exml_sample_read_file] TEST_INFO("parse ret = " << retParse); TEST_INFO("Debug display of the tree:"); doc.display(); } static void readFromString1() { exml::Document doc; TEST_INFO("parse"); //! [exml_sample_read_stream1] etk::String stream = "" "" "coucou"; bool retParse = doc.parse(stream); //! [exml_sample_read_stream1] TEST_INFO("parse ret = " << retParse); TEST_INFO("Debug display of the tree:"); doc.display(); } static void readFromString2() { exml::Document doc; TEST_INFO("parse"); //! [exml_sample_read_stream2] etk::String stream = "" "" "coucou"; bool retParse = doc.parse(stream); //! [exml_sample_read_stream2] TEST_INFO("parse ret = " << retParse); TEST_INFO("Debug display of the tree:"); doc.display(); } static void readFull() { exml::Document doc; TEST_INFO("parse"); bool retParse = doc.load(etk::Uri("DATA:///read.xml")); TEST_INFO("parse ret = " << retParse); TEST_INFO("Debug display of the tree:"); doc.display(); TEST_INFO("list of attribute:"); for (auto it: doc.attributes) { TEST_INFO(" " << it); } TEST_INFO("list of sub-node:"); for (const auto it: doc.nodes) { TEST_INFO(" " << it); if (it.isElement() == false) { continue; } exml::Element elem = it.toElement(); if (elem.exist() == false) { continue; } TEST_INFO(" list of attribute:"); for (const auto itElem: elem.attributes) { TEST_INFO(" " << itElem); } TEST_INFO(" list of sub-node:"); for (const auto itElem: elem.nodes) { TEST_INFO(" " << itElem); } } TEST_INFO(" Direct get node exml:"); //! [exml_sample_read_get_node] exml::Element element = doc.nodes["exml"]; //! [exml_sample_read_get_node] TEST_INFO(" list of attribute:"); //! [exml_sample_read_folow_attributes] for (const auto itElem: element.attributes) { etk::String value = itElem.getValue(); TEST_INFO(" '" << value << "'"); } TEST_INFO(" list of attribute in C:"); //! [exml_sample_read_folow_attributes] //! [exml_sample_read_folow_attributes_c] for (size_t iii=0; iii