From the post of the full code of the xml reader project, full code here.
Here is how to compile it up and also link to a basic main run method.
Compile up
g++ cppxmlreader.cpp -c |
will create the cppxmlreader.o (which is the object file) if you do file on the object the outout would be
file cppxmlreader.o cppxmlreader.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped |
and then using this code xmlreadmain.cpp
#include "cppxmlreader.h" int main(int argv, char** argc) { xmlReader xmlRead; xmlRead.loadFile("words.xml"); xmlRead.printOuterXML(); return 0; } |
This will include the header file of the cppxmlreader.h and then create a xmlReader object and load a basic file of words.xml and then print out the xml read in.
Here is the words.xml
<?xml version="1.0" encoding="UTF-8"?> <words> <word attname="hi">merry</word> <word>old</word> <word>sole</word> <word>was</word> <word>he</word> </words> |
and to compile up the main run the cppxmlreader.o is the object file from the above compiling and the xmlreadmain.cpp is the main runner with -o being the output name of the executable.
g++ xmlreadmain.cpp cppxmlreader.o -o xmlreader |
and if you run the xmlreader, the output should be
XML Reader Main Object (Xml main details) XML Object Tagname : Tagvalue : Attribute 0 : Name : version Value : 1.0 Attribute 1 : Name : encoding Value : UTF-8 XML Reader xml details XML Object Tagname :words Tagvalue : XML Object Tagname :word Tagvalue :merry Attribute 0 : Name : attname Value : hi XML Object Tagname :word Tagvalue :old XML Object Tagname :word Tagvalue :sole XML Object Tagname :word Tagvalue :was XML Object Tagname :word Tagvalue :he XML Object Tagname :/words Tagvalue : |