PHP implementation-XML + XSL = html

Source: Internet
Author: User
Tags xsl xsl file

Copyright statement: original works can be reproduced. During reprinting, you must mark the original publication, author information, and this statement in hyperlink form. Otherwise, legal liability will be held. Http://blog.csdn.net/mayongzhan-ma yongzhan, myz, mayongzhan

Run echo. php, OK,

XML is displayed in XSL format

// Main file: Echo. php // ---------------------------------------------------------- <? PHP/*** @ name echo. PHP * @ date Fri Sep 21 00:43:33 CST 2007 * @ copyright Ma yongzhan (myz) * @ author ma yongzhan (myz) * @ link http://blog.csdn.net/mayongzhan/ */header ("Content-Type: text/html; charset = UTF-8 "); $ xml = new domdocument (); $ XML-> load (" data. XML "); $ XSL = new domdocument (); $ XSL-> load (" style. XSL "); $ export proc = new export tprocessor (); $ export proc-> importstylesheet ($ XSL); echo $ export proc-> transformtoxml ($ XML);?> // XML file: Data. xml // ----------------------------------------------------------- <? XML version = "1.0" encoding = "UTF-8"?> <Works> <work name = "architecture"/> <work name = "management"/> <work name = "business"/> </Works> // XSL file: style. XSL // ------------------------------------------------------------- <? XML version = "1.0" encoding = "UTF-8"?> <XSL: stylesheet xmlns: XSL = "http://www.w3.org/1999/XSL/Transform" version = "1.0"> <XSL: output method = "html"/> <XSL: template match = "/"> <HTML> <body> <XSL: For-each select = "/Works/Work"> <XSL: value-of select = "@ name"/> <br/> </XSL: For-each> </body>

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.