Php, XML, XSLT, Mysql, and code

Source: Internet
Author: User
Tags dsn xsl file xslt

<? Php (as the mainstream development language)
Require_once "DB. php (as the mainstream development language)"; // database processing class in PEAR
$ DataType = "MySQL (the best combination with PHP)"; // Database Type
$ User = "root"; // user Name
$ Pass = "abcd"; // Password
$ Host = "202.96.215.200"; // MySQL (best combination with PHP) database server address
$ Db_name = "test"; // Database Name
$ Dsn = "$ dataType: // $ user: $ pass @ $ host/$ db_name"; // configure the DNS for connecting to the database
$ Db = DB: connect ($ dsn); // connect to the database
If (DB: isError ($ db ))
{
Die ($ db-> getMessage (); // connection failed, error message output
}

// The following two are public functions.
/**
* Reading the xsl document
*
* @ Param String $ filename-xsl file name
* @ Return string
*/
Function readXsl ($ filename)
{
If (false = file_exists ($ filename ))
{
Echo "the file to be read <font color = red> $ filename </font> does not exist </br/> ";
Return false;
}
Return implode (, file ($ filename ));
} // End function readXsl

/**
* Convert xml (standardization is getting closer and closer) files or array variables into HTML content based on the xsl File
* Http://www.acnow.net/
* @ Param array $ arydata-array variable
* @ Param String $ response String-xsl document data
* @ Param String $ xml (standardization is getting closer and closer) string-xml (standardization is getting closer and closer) document data
*/
Function getHtml ($ arydata = false, $ annotate string = false, $ xml (standardization is getting closer and closer) string = false)
{
Global $ db; // use the $ db object
Include_once ("xml (standardization is getting closer and closer)/sql2xml (standardization is getting closer and closer ). php (as the mainstream development language) "); // includes sql2xml (standardization is getting closer and closer)
$ Sql2xml (standardization is getting closer and closer) class = new xml (standardization is getting closer and closer) _ sql2xml (standardization is getting closer and closer) ($ db ); // instantiate sql2xml (standardization is getting closer and closer)
$ Sql2xml (standardization is getting closer and closer) class-> setEncoding ("GB2312"); // sets the data transcoding type
If (false = $ xml (standardization is getting closer and closer) string) {// if the user passes in the array data, apply the array data to xsl
// Set the node name for generating xml (standardization is getting closer and closer) document data

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.