{"id":17231,"date":"2015-09-18T05:01:25","date_gmt":"2015-09-17T19:01:25","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=17231"},"modified":"2016-10-12T21:24:43","modified_gmt":"2016-10-12T11:24:43","slug":"xml-to-html-data-intelligence-translation-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/xml-to-html-data-intelligence-translation-tutorial\/","title":{"rendered":"XML to HTML Data Intelligence Translation Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/xml_to_html.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"XML to HTML Data Intelligence Translation Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/xml_to_html.jpg\" title=\"XML to HTML Data Intelligence Translation Tutorial\"  style=\"float:left;\" id='xtho' onmouseover=\" this.src=this.src.replace('.png','.xgif').replace('.gif','.xjpg').replace('.jpg','.xpng').replace('.x','.');   \"  \/><\/a><p class=\"wp-caption-text\">XML to HTML Data Intelligence Translation Tutorial<\/p><\/div>\n<p>Yesterday, with <a target=_blank title='HTML Data Intelligence More Like XML Primer Tutorial' href='#hdimlxpt'>HTML Data Intelligence More Like XML Primer Tutorial<\/a> as shown below, we talked about the <a target=_blank title='HTML5 information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/HTML5'>HTML5<\/a> Global Attributes under the umbrella of <a target=_blank title='HTML data-* Attributes information from w3schools' href='http:\/\/www.w3schools.com\/tags\/att_global_data.asp'>HTML data-* Attribute<\/a> usage.<\/p>\n<p>You&#8217;d be right in guessing that now we want to try some <a target=_blank title='JSON information from w3schools' href='http:\/\/www.w3schools.com\/xml\/default.asp'>XML<\/a> to HTML translations making use of this.<\/p>\n<p>Along the way doing this we want to mention PHP&#8217;s simplexml methods you can read about at <a target=_blank href='http:\/\/www.w3schools.com\/php\/php_ref_simplexml.asp'>this link<\/a>, which are powerful if you know what the data structure involved is.  But today we are writing a home grown translator (or XML parser) to translate XML to HTML in a more &#8220;act dumb&#8221; generic sense, where you assume no knowledge of the data structure.  We acknowledge that it may fall over for some data, especially as the concept is in its infancy.<\/p>\n<p>The HTML code you can call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/xml_to_html.html_GETME\" title='xml_to_html.html'>xml_to_html.html<\/a> supervises some PHP you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/xml_to_html.php_GETME\" title='xml_to_html.php'>xml_to_html.php<\/a> (which has the dual purpose of demonstrating simplexml and accepting POSTed user defined data (to translate) from the HTML form of its parent).  The parent offers two forms for &#8230;<\/p>\n<ol>\n<li>small amounts of XML data using method=&#8217;GET&#8217; to xml_to_html.html<\/li>\n<li>large amounts of XML data using method=&#8217;POST&#8217; to xml_to_html.php (which clones xml_to_html.html to some user specific HTML that it calls)<\/li>\n<\/ol>\n<p>Our tutorial today thanks w3schools for some XML examples from <a target=_blank href='http:\/\/www.w3schools.com\/xml\/xml_attributes.asp' title='useful link'>this link<\/a> and <a target=_blank href='http:\/\/www.w3schools.com\/xml\/simple.xml' title='useful link again'>that link<\/a>.<\/p>\n<p>So please try a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/xml_to_html.html\" title='click picture'>live run<\/a> and do some XML to HTML translations that try to retain &#8220;data intelligence&#8221;, in sympathy with the HTML DOM <a target=_blank title='HTML DOM getAttribute method information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/met_element_getattribute.asp'>getAttribute<\/a> method available in Javascript.<\/p>\n<hr>\n<p id='hdimlxpt'>Previous relevant <a target=_blank title='HTML Data Intelligence More Like XML Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/html-data-intelligence-more-like-xml-primer-tutorial\/'>HTML Data Intelligence More Like XML Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sidtest.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"HTML Data Intelligence More Like XML Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sidtest.jpg\" title=\"HTML Data Intelligence More Like XML Primer Tutorial\"  style=\"float:left;\"  \/><\/a><p class=\"wp-caption-text\">HTML Data Intelligence More Like XML Primer Tutorial<\/p><\/div>\n<p>Today we wanted to start you thinking on the subject of &#8220;data with intelligence&#8221;.  Maybe you think of HTML as representing &#8220;data with intelligence&#8221; because it brings you, via the Internet so much great information.  That is true, but generally speaking, it is carrying &#8220;display&#8221; information, if it has not been massaged through a server side language, nor through some Ajax &#8220;smarts&#8221; that will pick up &#8220;data intelligence&#8221;.  The bottom line is, generally speaking, it is not carrying the structured &#8220;intelligence&#8221; (the <a target=_blank title='Protocol information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Protocol'>protocols<\/a>) <a target=_blank title='JSON information from w3schools' href='http:\/\/www.w3schools.com\/xml\/default.asp'>XML<\/a> and <a target=_blank title='XML information from w3schools' href='http:\/\/www.w3schools.com\/json\/default.asp'>JSON<\/a> (often) carry.<\/p>\n<p>However, HTML can be structured to be more like XML, and we delve into a bit of this by talking about a set of HTML Global Attributes that were added when <a target=_blank title='HTML5 information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/HTML5'>HTML5<\/a> came out, which you can read more about with the link <a target=_blank title='HTML data-* Attributes information from w3schools' href='http:\/\/www.w3schools.com\/tags\/att_global_data.asp'>HTML data-* Attribute<\/a>.<\/p>\n<p>We have a dual purpose with today&#8217;s illustrative &#8230;<\/p>\n<ol>\n<li>HTML <a target=_blank title='sidtest.html' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sidtest.html_GETME'>sidtest.html<\/a><\/li>\n<li>Javascript <a target=_blank title='sidtest.js' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sidtest.js_GETME'>sidtest.js<\/a><\/li>\n<\/ol>\n<p> &#8230; which is &#8230;<\/p>\n<ol>\n<li>this &#8220;poking our toes into the water&#8221; approach to <a target=_blank title='HTML data-* Attributes information from w3schools' href='http:\/\/www.w3schools.com\/tags\/att_global_data.asp'>HTML data-* Attribute<\/a> HTML &#8220;data with intelligence&#8221; (as illustrated, in the code with all the HTML element <i>data-type=&#8221;[HTML-element-type]&#8221;<\/i> usages (<a target=_blank title='?' href='http:\/\/www.youtube.com\/watch?v=vVr6b9851Xk'>shaken, not stirred<\/a>) throughout, like (the header &lt;head&gt; &#8230; &lt;\/head&gt; section&#8217;s) &#8230;<br \/>\n<code><br \/>\n&lt;title <i>data-type=\"title\"<\/i> id='myhtitle' title='myhtitle title'&gt;HTML Header Id and Title Proof of Concept Ideas of Source Code Printout - RJM Programming - September, 2015&lt;\/title&gt;<br \/>\n<\/code><br \/>\n&#8230; and how, subsequently, you could use Javascript code like &#8230;<br \/>\n<code><br \/>\n var huh=document.getElementById('myhtitle');<br \/>\n alert('Your HTML tag ' + huh.<a target=_blank title='HTML DOM getAttribute method information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/met_element_getattribute.asp'>getAttribute<\/a>('data-type') + ' element has content as per ' + huh.innerHTML);<br \/>\n<\/code><br \/>\n&#8230; to access this information) &#8230;<\/li>\n<li>getting used to the idea that all HTML elements, even those in the header &lt;head&gt; &#8230; &lt;\/head&gt; section (as well as the usual body &lt;body&gt; &#8230; &lt;\/body&gt; section) can be assigned id= (and that you can make use of these) &#8230; even inline Javascript &lt;script&gt; &#8230; &lt;\/script&gt; elements<\/li>\n<\/ol>\n<p>How are these related?  It&#8217;s all to do with using Javascript to make use of the HTML <i>slightly<\/i> less in terms of a carrier of &#8220;display&#8221; information, and <i>slightly<\/i> more as, possibly, also a carrier of &#8220;data intelligence&#8221;.  Even though there is, now with HTML5, the existence of <a target=_blank title='HTML data-* Attributes information from w3schools' href='http:\/\/www.w3schools.com\/tags\/att_global_data.asp'>HTML data-* Attribute<\/a> to help facilitate some of these thoughts for the use of some &#8220;data intelligence&#8221; with HTML, you should go easy on this, perhaps, as the most efficient way to proceed when there is lots of data, as XML was designed for &#8220;data intelligence&#8221; that is &#8220;big time&#8221; or dealing with large data sets, but you may have a modest application where you want to &#8220;carry&#8221; that small amount of database &#8220;data intelligence&#8221; with you in your HTML, and maybe &#8220;kill two birds with one stone&#8221;, those two birds being the &#8220;display bird&#8221; and the &#8220;data intelligence bird&#8221; &#8230; please note, <i>no magpies were hurt during the construction of this blog posting<\/i>.<\/p>\n<p>The functionality of today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sidtest.html\" title='click picture'>live run<\/a> is to &#8220;print out&#8221; (on a web browser) the coding of our <a target=_blank title='sidtest.html' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sidtest.html_GETME'>sidtest.html<\/a>, and so, by running it, you&#8217;ll see what we mean.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d17207' onclick='var dv=document.getElementById(\"d17207\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/?tag=xml\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d17207' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d17231' onclick='var dv=document.getElementById(\"d17231\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/?tag=html5\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d17231' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday, with HTML Data Intelligence More Like XML Primer Tutorial as shown below, we talked about the HTML5 Global Attributes under the umbrella of HTML data-* Attribute usage. You&#8217;d be right in guessing that now we want to try some &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/xml-to-html-data-intelligence-translation-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/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":[9,12,37],"tags":[1688,263,1689,354,1690,576,1687,578,652,664,997,1301,1319,1480],"class_list":["post-17231","post","type-post","status-publish","format-standard","hentry","category-database","category-elearning","category-tutorials","tag-attributes","tag-conversion","tag-data-intelligence","tag-dom","tag-getattribute","tag-html","tag-html-global-attributes","tag-html5","tag-javascript","tag-json","tag-programming","tag-translation","tag-tutorial","tag-xml"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/17231"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=17231"}],"version-history":[{"count":6,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/17231\/revisions"}],"predecessor-version":[{"id":25665,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/17231\/revisions\/25665"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=17231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=17231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=17231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}