C++ tinyxml2::XMLNode::Value()














































C++ tinyxml2::XMLNode::Value()




Value() method of Tinyxml2 is used to get the Value of Tinyxml2Node.


The meaning of 'value' changes for the specific type of Tinyxml2Node.


 Document: filename of the xml file
 Element:    name of the element
 Comment:  the comment text
 Unknown:  the tag contents
 Text:          the text string


The subclasses will wrap this function.


Syntax:-

const char* tinyxml2::XMLNode::Value() const



Example:-


Value_demo_file.xml-

<AnimalList>


  <animal>

       
<name>Herby</name>


  </animal>


</AnimalList>


Value.cpp (Filename) -

/*include necessary header files*/

#include <iostream>


#include <cstdlib>


#include "tinyxml2.h"


using namespace std;


using namespace tinyxml2;


int main()


{

   
XMLDocument doc;

  
doc.LoadFile(
"Value_demo_file.xml");


cout << " Output : Using Value() " << endl;

   
XMLElement* first_child_element = doc.FirstChildElement();

   
cout
<< "This is First Child Element :" <<first_child_element->Value() << endl;


return 0;


}


Output :-

 Output : Using Value()

 This is First Child Element : AnimalList

                     

                      



Comments