Sometimes to make a program practically useful you have to take a pause after the proof of concept stage and ask “would you be happy using this program if there was a deadline”. Yesterday’s version of our “Tags Within Tags” program would probably not have passed this test, but today’s more open version may go some way further down that track. Today we take yesterday’s PHP Nested Elements Report Primer Tutorial 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’s web server (we hope), we open up the functionality to allow:
- a comma separated list of URLs
- the analysis of local (rjmprogramming.com.au web server) 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 * to specify a filespec of files of interest … say (rjmprogramming.com.au web server) because if you run this from the rjmprogramming.com.au domain the word local means rjmprogramming.com.au‘s web server, but if you were to download the code further below and implement it onto a local (MAMP) web server, for instance, local could make (the meaning of) file:// refer to directories of your local (Mac laptop) disk
Yet to come is software integration to hook into the local client file system access to files that we could examine … see PHP/Javascript Replace String File Browsing Tutorial … maybe tomorrow?!
How these changes affected the code can be seen with tags_within.php link.
Let’s, below, recap the whole premise of the program … chow for now …
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.
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, Ajax techniques may be okay to use too, because we are not writing files, as such, here, today, but just reporting on files … subtle difference, but important, because Ajax techniques can read file data, but cannot write to files … the writing to files (on the web server) is where PHP (or ASP.Net) or other server side languages really need to be used.
With XML data in particular, data element attributes 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 attribute search string, then you can narrow down the parent tag scope of interest, to those only containing this attribute search string … and I guess you could kludge this for HTML data, perhaps with a unique classname or id or style= property perhaps.
You are welcome trying it here with a live run.
Here is a tailored call of the PHP that matches what is on today’s tutorial’s picture as a live run you can try to search the Google search engine landing webpage’s input tags nested within form tags, as an example of things you can try … hope it can be of interest, or help.
You can download PHP programming source code and rename to tags_within.php here.
Previous relevant PHP Nested Elements Report Primer Tutorial is shown below.
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.
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, Ajax techniques may be okay to use too, because we are not writing files, as such, here, today, but just reporting on files … subtle difference, but important, because Ajax techniques can read file data, but cannot write to files … the writing to files (on the web server) is where PHP (or ASP.Net) or other server side languages really need to be used.
With XML data in particular, data element attributes 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 attribute search string, then you can narrow down the parent tag scope of interest, to those only containing this attribute search string … and I guess you could kludge this for HTML data, perhaps with a unique classname or id or style= property perhaps.
You are welcome trying it here with a live run.
Here is a tailored call of the PHP that matches what is on today’s tutorial’s picture as a live run you can try to search the Google search engine landing webpage’s input tags nested within form tags, as an example of things you can try … hope it can be of interest, or help.
You can download PHP programming source code and rename to tags_within.php here.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.