Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/query_examples.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of J.  >  HTML SQL  >  examples/query_examples.txt  >  Download  
File: examples/query_examples.txt
Role: Documentation
Content type: text/plain
Description: Some query examples for copy and paste
Class: HTML SQL
Parse and extract information from HTML using SQL
Author: By
Last change:
Date: 2006-05-08 06:31
Size: 1,136 bytes
 

Contents

Class file image Download
Some query examples for copy & paste ;-)


SELECT * FROM h1
^ select all <h1> tags


SELECT * FROM a
^ select all links


SELECT * FROM td
^ select all <td>'s


SELECT href as url, text FROM a
^ return href as url and text as text from all links


SELECT * FROM a WHERE preg_match("/^http:\/\//", $href)
^ find all external links


SELECT * FROM a WHERE preg_match("/^\/snippets/i", $href) and preg_match("/^array_/i", $text)
^ find all links starting with /snippets and with a link text starting with "array_"


SELECT * FROM *
^ select all attributes of all tags ;-)


SELECT id, name, password FROM user WHERE $status == "active"
^ select all <user> tags where status="active" (for XML files)


SELECT * FROM * WHERE $id == "header"
^ return all tags with the $id = header


SELECT * FROM a WHERE substr($href,0,1) != "/"
^ select links with URLs that start with / (mainly internal links)


SELECT * FROM * WHERE $class == "nav_item"
^ select all tags with the class = nav_item


SELECT * FROM a WHERE ($href == "foo.htm" and $title == "foo") or ($title == "bar")
^ complex query