Quickly build an extensible Web site _php tutorials based on xml+xslt+css+php

Source: Internet
Author: User
Tags xsl xslt
1. Let the data and the display separate Test.xml data: Test title Test Content Banner Sidebar main body end of the page Test.xslt templates: test Link rel= "stylesheet" "type=" "Text/css" "href=" "Test.css" "> ]]> 2. The Web page automatically generates a PHP program to read the config file to generate the Target page config file based on the target file name and data file names and template file names specified in the files: test.html test.xml test.xslt PHP Code: Load ("$xsl"); $xmlDoc = new DOMDocument (), $xmlDoc->load ("$xml"); $proc = new Xsltprocessor (), $proc->importstylesheet ($xslDoc), $html = $proc->transformtoxml ($XMLDOC); if (! ( $filehandler = fopen ($name, "w+")) {die ("could not open $name output"), Fwrite ($filehandler, $html); Fclose ($filehandler);} $parser = Xml_parser_create (); Xml_set_element_handler ($parser, "startelement", "endElement"); Xml_set_character_data_handler ($parser, " Characterdata "); if (! ( $filehandler = fopen ($xml _file, "R")) {die (' could not open XML input '),} while ($data = Fread ($filehandler, 4096)) {if (!XM L_parse ($parser, $data, feof ($filehandler))) {Die (sprintf ("XML error:%s @ line%d", Xml_error_string (xml_get_error_ Code ($PARSER)), Xml_get_current_line_number ($parser)));}} Fclose ($filehandler); Xml_parser_free ($parser); foreach ($arr as $sub _arr) {$i = 0;foreach ($sub _arr as $obj) {if ($i = = 0) {$name = $obj;} if ($i = = 1) {$xml = $obj;} if ($i = = 2) {$xsl = $obj;} $i + +;} Buildhtml ($name, $xml, $xsl); }?> 3. Re-planning the entirePage Such a split-style design can make the page more flexible, arbitrarily modify any part of the rest of the block will not affect, and can constantly transform one of the pieces of data such as: Body.xml to generate more new pages, especially suitable for the news system or forum to use Top.xml:

http://www.bkjia.com/PHPjc/486275.html www.bkjia.com true http://www.bkjia.com/PHPjc/486275.html techarticle 1. Let data and display separate Test.xml data: XML titletest title/title contenttest content/content topbanner/top leftsidebar/left Bodymain body/body EndEnd of the Page/end/xml test ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.