{"id":528,"date":"2010-01-15T15:08:47","date_gmt":"2010-01-15T15:08:47","guid":{"rendered":"http:\/\/www.codingfriends.com\/?page_id=528"},"modified":"2010-01-21T12:04:29","modified_gmt":"2010-01-21T12:04:29","slug":"xml-reader-cpp","status":"publish","type":"page","link":"https:\/\/www.codingfriends.com\/index.php\/projects\/xml-reader-cpp\/","title":{"rendered":"XML reader &#8211; c++"},"content":{"rendered":"<p>An xml file would like similar to below.<\/p>\n<pre lang=\"xml\">\r\n<?xml version=\"1.0\"?>\r\n<root>\r\n  <words>one<\/words>\r\n  <words>two<\/words>\r\n<\/root>\r\n<\/pre>\n<p>The first line, if present, could ignore at present, just save the version in a variable.<\/p>\n<p>Idea of process, <\/p>\n<p>1. Get element &#8211; add element name to a array stack (push)<br \/>\n2. get value if present.<br \/>\n3. if end of element then pop the array stack (array stack would be null in this instance)<\/p>\n<p>repeat the above for the xml example above it would be<br \/>\n1. element = root, array stack = root<br \/>\n2. no value<br \/>\n3. not the end of element goto 1.<br \/>\n    1 element = words, array stack = words, root.<br \/>\n    2.value = one<br \/>\n    3. end of element, pop stack, array stack = root (check popped stack in the same as the end element else ERROR.<\/p>\n<p>always check for errors, e.g. end of file etc.  and whilst going through the xml file, place the details into a object so that it can be &#8220;viewed&#8221; from within the c++ program.<\/p>\n<p>this will just be a version 0.1 as such, a basic reader.  if I carry it on then<br \/>\nversion 0.2 would have attributes pull<br \/>\nversion 0.3 xpath<br \/>\nand then version 0.4 other parts.. checking against version numbers etc.<\/p>\n<p>Here are the different parts of the xml reader object that I created.<br \/>\n<a href=\"http:\/\/www.codingfriends.com\/index.php\/2010\/01\/21\/xml-attributes-cpp\/\">xmlAttribute<\/a><br \/>\n<a href=\"http:\/\/www.codingfriends.com\/index.php\/2010\/01\/21\/xml-object-cpp\/\">xmlObject<\/a><br \/>\n<a href=\"http:\/\/www.codingfriends.com\/index.php\/2010\/01\/21\/xml-reader-cpp\/\">xmlReader<\/a><\/p>\n<p>Here is the two files together.<br \/>\n<a href=\"http:\/\/www.codingfriends.com\/index.php\/2010\/01\/21\/xml-reader-full-cpp\/\">xmlReader<\/a><\/p>\n<p>and to all join together and call<br \/>\n<a href=\"http:\/\/www.codingfriends.com\/index.php\/2010\/01\/21\/xml-reader-compile-and-link-cpp\/\">compile and run.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>An xml file would like similar to below. one two The first line, if present, could ignore at present, just save the version in a variable. Idea of process, 1. Get element &#8211; add element name to a array stack (push) 2. get value if present. 3. if end of element then pop the array &hellip; <a href=\"https:\/\/www.codingfriends.com\/index.php\/projects\/xml-reader-cpp\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">XML reader &#8211; c++<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":34,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-528","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/pages\/528","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"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=528"}],"version-history":[{"count":9,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/pages\/528\/revisions"}],"predecessor-version":[{"id":555,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/pages\/528\/revisions\/555"}],"up":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/pages\/34"}],"wp:attachment":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/media?parent=528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}