Reading XML and HTML documents with SQL statements

Source: Internet
Author: User
Tags exit php class
xml| statement

A Super cow PHP class that was discovered today from Phpclasses.org, the most special of which is that you can use SELECT statements to read specific data from XML and HTML documents. For example, here is an example:

<?php

/*
* * Htmlsql-example 1
**
* * A simple example of a query
*/
Include class file
Include_once (".. /snoopy.class.php ");
Include_once (".. /htmlsql.class.php ");
Creating objects
$wsql = new Htmlsql ();

URL on connection
if (! $wsql->connect (' url ', '/')) {
print ' Error while connecting: '. $wsql->error;
Exit
}

/* Execute Query
SELECT * from a reads all the <a> tags in the HTML of the phpchina.cn home page
*/
if (! $wsql->query (' SELECT * from a ')) {
Print "Query error:". $wsql->error;
Exit
}

Output results:
foreach ($wsql->fetch_array () as $row) {
Print_r ($row);
/*
$row is an array like the following:
Array (
[href] =>/index.html
[TagName] => A
[Text] => Home
)
*/
}
?>

Author of this class: Jonas John
Personal homepage: http://www.jonasjohn.de/
Age: 20



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.