PHP Nested Elements Report Primer Tutorial

PHP Nested Elements Report Primer Tutorial

PHP Nested Elements Report Primer Tutorial

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.

This entry was posted in eLearning, Tutorials and tagged , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *