{"id":10759,"date":"2014-11-24T05:02:13","date_gmt":"2014-11-23T18:02:13","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=10759"},"modified":"2014-11-24T05:02:13","modified_gmt":"2014-11-23T18:02:13","slug":"php-nested-elements-report-client-files-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/php-nested-elements-report-client-files-tutorial\/","title":{"rendered":"PHP Nested Elements Report Client Files Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/tags_within.php\"><img decoding=\"async\" id='fsqxmximgjoptionpane'  style=\"float:left; border: 15px solid pink;\" alt=\"PHP Nested Elements Report Client Files Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/tag_within_local.jpg\" title=\"PHP Nested Elements Report Client Files Tutorial\" id=\"qwpnerpt\"  \/><\/a><p class=\"wp-caption-text\">PHP Nested Elements Report Client Files Tutorial<\/p><\/div>\n<p><i>&#8220;Tomorrow&#8221;<\/i> is now <i>&#8220;today&#8221;<\/i>, and the Earth has had another roll &#8230; just like my dog in the park when there is <i>&#8220;good stuff&#8221;<\/i> present &#8230; please don&#8217;t ask?!<\/p>\n<p>Maybe yesterday&#8217;s blurb got you looking at <a target=_blank title='PHP\/Javascript Replace String File Browsing Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=10545'>PHP\/Javascript Replace String File Browsing Tutorial<\/a> and its use of the wonderful HTML5 File API functionality.   This is what gets used here today, to be able to report <i>&#8220;Tags Within Tags&#8221;<\/i> for local client files (ie. on your client laptop or desktop or mobile (as applicable) hard disk (as applicable)) so that a webpage or web application acts a lot like a desktop program with those ever so familiar <i>&#8220;Browse&#8230;&#8221;<\/i> button scenarios (hopefully you forget you are on the web).<\/p>\n<p>How these changes affected the code can be seen with <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/tags_within.php--GETME\" title='tags_within.php'>tags_within.php<\/a> link.<\/p>\n<p>How these changes affected the supervisory code can be seen with <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/fileinfotable.php-----------GETME\" title='fileinfotable.php'>fileinfotable.php<\/a> link.<\/p>\n<p>So maybe you should recap the story as below, as to why we are doing this &#8230; <\/p>\n<p>Sometimes to make a program practically useful you have to take a pause after the proof of concept stage and ask &#8220;would you be happy using this program if there was a deadline&#8221;.  Yesterday&#8217;s version of our <i>&#8220;Tags Within Tags&#8221;<\/i> program would probably not have passed this test, but today&#8217;s more open version may go some way further down that track.   Today we take yesterday&#8217;s <a target=_blank href='#pnerpt' title='PHP Nested Elements Report Primer Tutorial'>PHP Nested Elements Report Primer Tutorial<\/a> as shown below and extend it so that the report can be run with the one lot of interactive input for more than one URL at once, so, in order to open up the program, but still shield from a bombardment of this rjmprogramming.com.au&#8217;s web server (we hope), we open up the functionality to allow:<\/p>\n<ul>\n<li>a comma separated list of URLs<\/li>\n<li>the analysis of local <i>(rjmprogramming.com.au web server)<\/i> files in a list and\/or as a filespec using the file:\/\/ prefix syntax to specify a local file, along with the use of wildcards such as <i>*<\/i> to specify a filespec of files of interest &#8230; say <i>(rjmprogramming.com.au web server)<\/i> because if you run this from the <i>rjmprogramming.com.au<\/i> domain the word <i>local<\/i> means <i>rjmprogramming.com.au<\/i>&#8216;s web server, but if you were to download the code further below and implement it onto a local (MAMP) web server, for instance, <i>local<\/i> could make (the meaning of) <i>file:\/\/<\/i> refer to directories of your local (Mac laptop) disk<\/li>\n<\/ul>\n<p>Yet to come is software integration to hook into the local client file system access to files that we could examine &#8230; see <a target=_blank title='PHP\/Javascript Replace String File Browsing Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=10545'>PHP\/Javascript Replace String File Browsing Tutorial<\/a> &#8230; maybe tomorrow?!<\/p>\n<p>How these changes affected the code can be seen with <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/tags_within.php-GETME\" title='tags_within.php'>tags_within.php<\/a> link.<\/p>\n<p>Let&#8217;s, below, recap the whole premise of the program &#8230; chow for now &#8230;<\/p>\n<p>Lots of data is hierarchical by nature.   Examples are HTML or XML or JSON data, and to get a report on tag types nested within other tag types can be a useful tool to sanity check that your data is well structured, or is valid, perhaps.<\/p>\n<p>Because our input is a data file today (ie. implicitly, a URL amounts to a data file, somewhere, on a web server), we will need a server side language to work the functionality, though I daresay, <a target=_blank title='Ajax information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Ajax_%28programming%29'>Ajax<\/a> techniques may be okay to use too, because we are not writing files, as such, here, today, but just reporting on files &#8230; subtle difference, but important, because Ajax techniques can read file data, but cannot write to files &#8230; the writing to files (on the <a target=_blank title='Web sever information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Web_server'>web server<\/a>) is where PHP (or ASP.Net) or other server side languages really need to be used.<\/p>\n<p>With XML data in particular, data element <i>attributes<\/i> are often used as a place to contain important business logic that affects the structure of your data, so, here, with our PHP, we allow a simple arrangement, where if you can specify a unique <i>attribute<\/i> search string, then you can narrow down the parent tag scope of interest, to those only containing this <i>attribute<\/i> search string &#8230; and I guess you could <i>kludge<\/i> this for HTML data, perhaps with a unique <i>classname<\/i> or <i>id<\/i> or <i>style= property<\/i> perhaps.<\/p>\n<p>You are welcome trying it here with a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/tags_within.php\" title=\"Click picture\">live run<\/a>.<\/p>\n<p>You are also welcome trying its supervisor here with a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/fileinfotable.php\" title=\"Click picture of some time back\">supervisory live run<\/a>.<\/p>\n<p>Here is a tailored call of the PHP that matches what is on today&#8217;s tutorial&#8217;s picture as a <a target=_blank title='Google live run' href='http:\/\/www.rjmprogramming.com.au\/PHP\/tags_within.php?url=http%3A%2F%2Fwww.google.com&#038;ptag=form&#038;ctag=input&#038;attrib=&#038;start=%3C&#038;end=%3C%2F&#038;submit=Report'>live run<\/a> you can try to search the Google search engine landing webpage&#8217;s <i>input<\/i> tags nested within <i>form<\/i> tags, as an example of things you can try &#8230; hope it can be of interest, or help.<\/p>\n<p>You can download PHP programming source code and rename to <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/tags_within.php--GETME\" title='tags_within.php'>tags_within.php<\/a> here.<\/p>\n<p>You can download supervisory PHP programming source code and rename to <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/fileinfotable.php-----------GETME\" title='fileinfotable.php'>fileinfotable.php<\/a> here.<\/p>\n<hr \/>\n<p id='pnerfut'>Previous relevant <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=10744' title='PHP Nested Elements Report Follow Up Tutorial'>PHP Nested Elements Report Follow Up Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/tags_within.php\"><img decoding=\"async\" id='sqxmximgjoptionpane'  style=\"float:left; border: 15px solid pink;\" alt=\"PHP Nested Elements Report Follow Up Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/tag_within_more.jpg\" title=\"PHP Nested Elements Report Follow Up Tutorial\" id=\"pnerpt\" onmouseover=\" this.src=this.src.replace('.jpg','.GIF').replace('.png','.jpg').replace('.gif','.png').replace('.GIF','.gif');     \"  \/><\/a><p class=\"wp-caption-text\">PHP Nested Elements Report Follow Up Tutorial<\/p><\/div>\n<p>Sometimes to make a program practically useful you have to take a pause after the proof of concept stage and ask &#8220;would you be happy using this program if there was a deadline&#8221;.  Yesterday&#8217;s version of our <i>&#8220;Tags Within Tags&#8221;<\/i> program would probably not have passed this test, but today&#8217;s more open version may go some way further down that track.   Today we take yesterday&#8217;s <a target=_blank href='#pnerpt' title='PHP Nested Elements Report Primer Tutorial'>PHP Nested Elements Report Primer Tutorial<\/a> as shown below and extend it so that the report can be run with the one lot of interactive input for more than one URL at once, so, in order to open up the program, but still shield from a bombardment of this rjmprogramming.com.au&#8217;s web server (we hope), we open up the functionality to allow:<\/p>\n<ul>\n<li>a comma separated list of URLs<\/li>\n<li>the analysis of local <i>(rjmprogramming.com.au web server)<\/i> files in a list and\/or as a filespec using the file:\/\/ prefix syntax to specify a local file, along with the use of wildcards such as <i>*<\/i> to specify a filespec of files of interest &#8230; say <i>(rjmprogramming.com.au web server)<\/i> because if you run this from the <i>rjmprogramming.com.au<\/i> domain the word <i>local<\/i> means <i>rjmprogramming.com.au<\/i>&#8216;s web server, but if you were to download the code further below and implement it onto a local (MAMP) web server, for instance, <i>local<\/i> could make (the meaning of) <i>file:\/\/<\/i> refer to directories of your local (Mac laptop) disk<\/li>\n<\/ul>\n<p>Yet to come is software integration to hook into the local client file system access to files that we could examine &#8230; see <a target=_blank title='PHP\/Javascript Replace String File Browsing Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=10545'>PHP\/Javascript Replace String File Browsing Tutorial<\/a> &#8230; maybe tomorrow?!<\/p>\n<p>How these changes affected the code can be seen with <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/tags_within.php-GETME\" title='tags_within.php'>tags_within.php<\/a> link.<\/p>\n<p>Let&#8217;s, below, recap the whole premise of the program &#8230; chow for now &#8230;<\/p>\n<p>Lots of data is hierarchical by nature.   Examples are HTML or XML or JSON data, and to get a report on tag types nested within other tag types can be a useful tool to sanity check that your data is well structured, or is valid, perhaps.<\/p>\n<p>Because our input is a data file today (ie. implicitly, a URL amounts to a data file, somewhere, on a web server), we will need a server side language to work the functionality, though I daresay, <a target=_blank title='Ajax information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Ajax_%28programming%29'>Ajax<\/a> techniques may be okay to use too, because we are not writing files, as such, here, today, but just reporting on files &#8230; subtle difference, but important, because Ajax techniques can read file data, but cannot write to files &#8230; the writing to files (on the <a target=_blank title='Web sever information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Web_server'>web server<\/a>) is where PHP (or ASP.Net) or other server side languages really need to be used.<\/p>\n<p>With XML data in particular, data element <i>attributes<\/i> are often used as a place to contain important business logic that affects the structure of your data, so, here, with our PHP, we allow a simple arrangement, where if you can specify a unique <i>attribute<\/i> search string, then you can narrow down the parent tag scope of interest, to those only containing this <i>attribute<\/i> search string &#8230; and I guess you could <i>kludge<\/i> this for HTML data, perhaps with a unique <i>classname<\/i> or <i>id<\/i> or <i>style= property<\/i> perhaps.<\/p>\n<p>You are welcome trying it here with a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/tags_within.php\" title=\"Click picture\">live run<\/a>.<\/p>\n<p>You are welcome trying a supervisory way with a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/fileinfotable.php\" title=\"Click picture from some time back\">supervisory live run<\/a>.<\/p>\n<p>Here is a tailored call of the PHP that matches what is on today&#8217;s tutorial&#8217;s picture as a <a target=_blank title='Google live run' href='http:\/\/www.rjmprogramming.com.au\/PHP\/tags_within.php?url=http%3A%2F%2Fwww.google.com&#038;ptag=form&#038;ctag=input&#038;attrib=&#038;start=%3C&#038;end=%3C%2F&#038;submit=Report'>live run<\/a> you can try to search the Google search engine landing webpage&#8217;s <i>input<\/i> tags nested within <i>form<\/i> tags, as an example of things you can try &#8230; hope it can be of interest, or help.<\/p>\n<p>You can download PHP programming source code and rename to <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/tags_within.php-GETME\" title='tags_within.php'>tags_within.php<\/a> here.<\/p>\n<hr \/>\n<p id='pnerpt'>Previous relevant <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=10729' title='PHP Nested Elements Report Primer Tutorial'>PHP Nested Elements Report 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\/PHP\/tags_within.php\"><img decoding=\"async\" id='qxmximgjoptionpane'  style=\"float:left; border: 15px solid pink;\" alt=\"PHP Nested Elements Report Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/tags_within.jpg\" title=\"PHP Nested Elements Report Primer Tutorial\" id=\"pnerpt\" onmouseover=\" this.src=this.src.replace('.jpg','.GIF').replace('.png','.jpg').replace('.gif','.png').replace('.GIF','.gif');     \"  \/><\/a><p class=\"wp-caption-text\">PHP Nested Elements Report Primer Tutorial<\/p><\/div>\n<p>Lots of data is hierarchical by nature.   Examples are HTML or XML or JSON data, and to get a report on tag types nested within other tag types can be a useful tool to sanity check that your data is well structured, or is valid, perhaps.<\/p>\n<p>Because our input is a data file today (ie. implicitly, a URL amounts to a data file, somewhere, on a web server), we will need a server side language to work the functionality, though I daresay, <a target=_blank title='Ajax information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Ajax_%28programming%29'>Ajax<\/a> techniques may be okay to use too, because we are not writing files, as such, here, today, but just reporting on files &#8230; subtle difference, but important, because Ajax techniques can read file data, but cannot write to files &#8230; the writing to files (on the <a target=_blank title='Web sever information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Web_server'>web server<\/a>) is where PHP (or ASP.Net) or other server side languages really need to be used.<\/p>\n<p>With XML data in particular, data element <i>attributes<\/i> are often used as a place to contain important business logic that affects the structure of your data, so, here, with our PHP, we allow a simple arrangement, where if you can specify a unique <i>attribute<\/i> search string, then you can narrow down the parent tag scope of interest, to those only containing this <i>attribute<\/i> search string &#8230; and I guess you could <i>kludge<\/i> this for HTML data, perhaps with a unique <i>classname<\/i> or <i>id<\/i> or <i>style= property<\/i> perhaps.<\/p>\n<p>You are welcome trying it here with a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/tags_within.php\" title=\"Click picture\">live run<\/a>.<\/p>\n<p>Here is a tailored call of the PHP that matches what is on today&#8217;s tutorial&#8217;s picture as a <a target=_blank title='Google live run' href='http:\/\/www.rjmprogramming.com.au\/PHP\/tags_within.php?url=http%3A%2F%2Fwww.google.com&#038;ptag=form&#038;ctag=input&#038;attrib=&#038;start=%3C&#038;end=%3C%2F&#038;submit=Report'>live run<\/a> you can try to search the Google search engine landing webpage&#8217;s <i>input<\/i> tags nested within <i>form<\/i> tags, as an example of things you can try &#8230; hope it can be of interest, or help.<\/p>\n<p>You can download PHP programming source code and rename to <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/tags_within.php_GETME\" title='tags_within.php'>tags_within.php<\/a> here.<\/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='#d10729' onclick='var dv=document.getElementById(\"d10729\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=hierarchy\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d10729' 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='#d10744' onclick='var dv=document.getElementById(\"d10744\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=XML\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d10744' 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='#d10759' onclick='var dv=document.getElementById(\"d10759\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=API\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d10759' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;Tomorrow&#8221; is now &#8220;today&#8221;, and the Earth has had another roll &#8230; just like my dog in the park when there is &#8220;good stuff&#8221; present &#8230; please don&#8217;t ask?! Maybe yesterday&#8217;s blurb got you looking at PHP\/Javascript Replace String File &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/php-nested-elements-report-client-files-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":[12,14,37],"tags":[69,88,418,419,513,564,576,578,652,664,744,932,997,1240,1319,1345,1411,1480],"class_list":["post-10759","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-ajax","tag-api","tag-file","tag-file-api","tag-google","tag-hierarchy","tag-html","tag-html5","tag-javascript","tag-json","tag-mamp","tag-php","tag-programming","tag-tag","tag-tutorial","tag-url","tag-web-server","tag-xml"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/10759"}],"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=10759"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/10759\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=10759"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=10759"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=10759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}