Loading XML in PHP
<p>So far, we have seen examples of how applications on the client side in web-interactions load XML data that is rendered to them as the content format. We'll now take a look at PHP, a specialized server-side language that makes XML content available to client applications such as <a href="/html5/101.html">HTML</a> browsers, which then render this information as text in the browser window using special languages like <a href="/02geek/javascript/101.html">Javascript</a>. We'll start with a very simple example, using samples of XML information as well as a PHP script to load this document onto the browser application:</p> <p><?</p> <p>$xmlString = "<canine>who let the dogs out?</canine>"; </p> <p>echo $xmlString; </p> <p>?> </p> <p>When this information is fed to the browser, it displays the output "Who Let the Dogs out?" correctly. It displayed data because the root <a href=" /courses/video/47/396/Elements-and-Attributes-in-PHP.html">element</a> has no nested elements inside of it. If we store an XML document instead that consists of <a href="/courses/video/47/367/Nesting-Elements.html ">nested elements</a>, it doesn't make sense to display the contents of the root element on the browser. It's not a simple <a href="/courses/video/4/154/Strings-As-Our-First-Variable.html">string</a> any more. So it simply displays a blank page, with NO content. </p> <p><? <p>$xmlString = "<canine> </p> <p><question>Who Let the dogs out?</question> </p> <p><answer>It's a dog's life!</answer> </p> <p></canine>" </p> <p>echo $xmlString; </p> <p>?> </p> <p>In the next session we shall see what kind of PHP code needs to be written in order to parse any XML document and then give it to the client software (browser) so that only the content is correctly displayed. We can see the division of responsibilities between technologies and languages, all centered around content management. On the server side is PHP, and on the client side (mainly browsers,) it is Javascript. XML is the common glue that binds these technologies together, and provides a extensible and flexible framework for content management.</p>