{"id":553,"date":"2010-01-21T12:03:32","date_gmt":"2010-01-21T12:03:32","guid":{"rendered":"http:\/\/www.codingfriends.com\/?p=553"},"modified":"2010-01-21T12:03:32","modified_gmt":"2010-01-21T12:03:32","slug":"xml-reader-compile-and-link-cpp","status":"publish","type":"post","link":"https:\/\/www.codingfriends.com\/index.php\/2010\/01\/21\/xml-reader-compile-and-link-cpp\/","title":{"rendered":"XML reader compile and link &#8211; cpp"},"content":{"rendered":"<p>From the post of the full code of the <a href=\"http:\/\/www.codingfriends.com\/index.php\/projects\/xml-reader-cpp\/\">xml reader project<\/a>, <a href=\"http:\/\/www.codingfriends.com\/index.php\/2010\/01\/21\/xml-reader-full-cpp\/\">full code here<\/a>.<\/p>\n<p>Here is how to compile it up and also link to a basic main run method.<\/p>\n<p>Compile up <\/p>\n<pre lang=\"bash\">\r\ng++ cppxmlreader.cpp -c\r\n<\/pre>\n<p>will create the cppxmlreader.o (which is the object file) if you do file on the object the outout would be<\/p>\n<pre lang=\"bash\">\r\nfile cppxmlreader.o\r\ncppxmlreader.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped\r\n<\/pre>\n<p>and then using this code xmlreadmain.cpp<\/p>\n<pre lang=\"cpp\">\r\n#include \"cppxmlreader.h\"\r\n\r\nint main(int argv, char** argc)\r\n{\r\n    xmlReader xmlRead;\r\n    xmlRead.loadFile(\"words.xml\");\r\n    xmlRead.printOuterXML();\r\n    return 0;\r\n}\r\n<\/pre>\n<p>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.<\/p>\n<p>Here is the words.xml<\/p>\n<pre lang=\"xml\">\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<words>\r\n  <word attname=\"hi\">merry<\/word>\r\n  <word>old<\/word>\r\n  <word>sole<\/word>\r\n  <word>was<\/word>\r\n  <word>he<\/word>\r\n<\/words>\r\n<\/pre>\n<p>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. <\/p>\n<pre lang=\"bash\">\r\ng++ xmlreadmain.cpp cppxmlreader.o -o xmlreader\r\n<\/pre>\n<p>and if you run the xmlreader, the output should be<\/p>\n<pre lang=\"bash\">\r\nXML Reader Main Object (Xml main details)\r\nXML Object\r\nTagname  :\r\nTagvalue :\r\nAttribute 0 : Name : version Value : 1.0\r\nAttribute 1 : Name : encoding Value : UTF-8\r\nXML Reader xml details\r\nXML Object\r\nTagname  :words\r\nTagvalue :\r\nXML Object\r\nTagname  :word\r\nTagvalue :merry\r\nAttribute 0 : Name : attname Value : hi\r\nXML Object\r\nTagname  :word\r\nTagvalue :old\r\nXML Object\r\nTagname  :word\r\nTagvalue :sole\r\nXML Object\r\nTagname  :word\r\nTagvalue :was\r\nXML Object\r\nTagname  :word\r\nTagvalue :he\r\nXML Object\r\nTagname  :\/words\r\nTagvalue :\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/www.codingfriends.com\/index.php\/2010\/01\/21\/xml-reader-compile-and-link-cpp\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">XML reader compile and link &#8211; cpp<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[60],"class_list":["post-553","post","type-post","status-publish","format-standard","hentry","category-c_and_cpp","tag-xml"],"_links":{"self":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/553","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/comments?post=553"}],"version-history":[{"count":1,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/553\/revisions"}],"predecessor-version":[{"id":554,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/553\/revisions\/554"}],"wp:attachment":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/media?parent=553"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/categories?post=553"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/tags?post=553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}