pugixml intergration in visual studio code

72 Views Asked by At

am trying to read an xml file in visual studio using the pugixml parser. i have downloaded the parser. but am wondering how i can link it with my c++ code. like how to configure the include directories.here is my code

#include "pugixml.hpp"

#include <iostream>
using namespace std;


int main()
{
    pugi::xml_document doc;
    doc.load_file("XML.xml");           //Load xml file


    pugi::xml_node  efruit = doc.first_child().child("fruit");                //get the child fruit of first child of a xml document i.e file 

    while (efruit != NULL)
    {
        pugi::xml_node fName = efruit.child("name");                      //get the name child of fruit 



        if (fName != NULL)
        {
            cout << fName.text().get();                                  //print the name of fruit i.e text of name
        }


        pugi::xml_node fColor = efruit.child("color");                     //get the color child of fruit

        if (fColor != NULL)
        {
            cout << "  " << fColor.text().get();                        //print the color of fruit i.e text of color
        }
        cout << endl;
        efruit = efruit.next_sibling("fruit");                            //get the sibling of fruit i.e next fruit
    }
    return 0;
}
0

There are 0 best solutions below