TAILIEUCHUNG - OBJECT-ORIENTED PHP Concepts, Techniques, and Code- P13

OBJECT-ORIENTED PHP Concepts, Techniques, and Code- P13:A number of years ago, before I started using PHP, I created dynamic web pages using C. This really wasn’t too different from some of the other options available at the time, though it seems almost unthinkable now. Creating a dynamic page meant outputting HTML from your script and recompiling that script if any changes needed to be made. | HTML tags can have attributes. The major difference between XML tags and HTML tags is that HTML tags are predefined in XML you can define your own tags. It is this capability that puts the extensible in XML. The best way to understand XML is by examining an XML document. Before doing so let me say a few words about RSS documents. RSS Unfortunately there are numerous versions of RSS. Let s take a pragmatic approach and ignore the details of RSS s tortuous history. With something new it s always best to start with a simple example and the simplest version of RSS is version . This version has officially been declared obsolete but it is still widely used and knowledge of its structure provides a firm basis for migrating to version so your efforts will not be wasted. I ll show you an example of a version RSS file in fact it is the very RSS feed that we are going to use to display news items in a web page. Structure of an RSS File As we have done earlier with our own code let s walk through the RSS code commenting where appropriate. The very first component of an XML file is the version declaration. This declaration shows a version number and like the following example may also contain information about character encoding. xml version encoding iso-8859-1 After the XML version declaration the next line of code begins the very first element of the document. The name of this element defines the type of XML document. For this reason this element is known as the document element or root element. Not surprisingly our document type is RSS. This opening element defines the RSS version number and has a matching closing tag that terminates the document in much the same way that html and html open and close a web page. rss version A properly formatted RSS document requires a single channel element. This element will contain metadata about the feed as well as the actual data that makes up the feed. A channel element has three required sub-elements a title a .