Browsers are notorious for rendering HTML pages perfectly even when a page contains errors. For instance, a button may display properly but not function because of a missing closing tag. Hence the need for tools to check syntax. This is relatively straightforward for static HTML pages but what about dynamic pages? When server-side technologies such as PHP or ASP are used to create HTML pages dynamically, checking and debugging the result can be difficult. This article will show how this can be done using the free text editor, HTML-Kit. This will involve configuring some of the features of this editor. No knowledge of any specific technologies is required but a general knowledge of HTML and of the function of browsers and web servers is assumed.
Using HTML-Kit to Debug Server-Side Scripts - View Source and Validate (Page 4 of 4 )
As mentioned in my earlier article, one of the nicest features of HTML-Kit is the ability to preview your files. This capability is central to the current discussion. Briefly, to preview the current file all you need to do is click the "Preview" tab at the bottom of the "Editing Window". The application defaults to showing how your page will look in Internet Explorer.
Having configured HTML-Kit, we can now deal with the problem of validating files that need to be processed by the server. Open any file that dynamically generates HTML and then press the "Preview" tab. When your processed page shows, right click the preview window, avoiding any graphics, and then choose "View Source" from the pop-up menu. Doing this will open another window in HTML-Kit, a window that holds the HTML code as generated by your server.
A word of warning - make sure that you are previewing in Explorer Mode and not Gecko Mode. The preferences menu only allows you to view the source in Internet Explorer. If you are in Gecko mode this option will be disabled.
If your file has been properly processed by the server, you are now in a position to verify your dynamically created web page. HTML-Kit has the capability of checking HTML code by uploading it to an online mark-up validation service. By choosing the menu options "Actions" and then "Online" you will have two choices for validating your HTML file. You may use the Web Design Group (WDG) or the World Wide Web Consortium (W3C) validator. I prefer to use the W3C validator because this is the organization responsible for developing guidelines and standards for the web. Whichever service you choose, your file will be uploaded and a report generated. Any coding errors that exist will be referenced by line number. You can even print out your code with all the errors referenced. The W3C service will also inform you of any deviations from the standard - if you are missing the "alt" attribute from an "img" tag for instance. While these errors will not affect the functionality of your page, why not write code to conform to the standard? It will certainly improve the interoperability of your page and make it more user friendly.
Conclusion
Through a few rather simple steps HTML-Kit can be set up to validate HTML code generated by a server-side script. Dynamically created pages may be viewed in HTML-Kit and the resultant HTML page uploaded to a validation service to check its syntax. All this functionality integrated into one tool makes it an easy way to debug server-side scripts.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.