C++ tinyxml2::NextSibling()














































C++ tinyxml2::NextSibling()




NextSibling() method of Tinyxml2 is used to get next sibling of the node.It is used to navigate
to a next sibling node.


Syntax:-


XMLHandle NextSibling() 



Example:-


NextSibling_demo_file.xml-

<?xml version="1.0"?>

<Root_Element>

     <Child_1>This_is_Child_1_Content_Hello.</Child_1>

    <Child_2>This_is_Child_2_Content_Welcome to CppSecrets.com.</Child_2>

</Root_Element>


NextSibling.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(
"NextSibling_demo_file.xml");
   
cout
<< " Output : Using NextSibling()" << endl;
    
XMLNode* child_1 = doc.LastChild();
   
cout
<< "Last Child of  XML Document is : " << child_1->Value()<< endl;
   
XMLNode* child_2 = child_1->FirstChild();
   
cout
<< "First Child of " << child_1->Value()<< " is: " <<child_2->Value() << endl;
   
XMLNode* child_3 = child_2->NextSibling();
   
cout
<< "Next Sibling of " << child_2->Value()<< " is: " <<child_3->Value() << endl;
 
return 0;
}
 


Output:-


                



Comments