PHP ~ phpQuery example

this is an example......how to use phpQuery......
---------------------------------------------------------------------------------------------------

<?php
include 'phpQuery-onefile.php';
$content = '
<div class="bitty">
<span class="car1">Ferrari</span><br><span class="car2">Lamborghini</span>, <div class="car3">BMW</div> <div class="car4">Mc-Laren</div><br>
<div id="bittyferrari">Cool</div>
</div>
';

$doc = phpQuery::newDocument($content);
phpQuery::selectDocument($doc);
print 'car1: '.pq('.car1')->html();
print '<br>';
print 'car2: '. pq('.car2')->html();
print '<br>';
print 'car3: '.pq('.car3')->html();
print '<br>';
print 'car4: '.pq('.car4')->html();
print '<br>';
print 'bittyferrari: '.pq('#bittyferrari')->html();
?>

---------------------------------------------------------------------------------------------------

download:
http://code.google.com/p/phpquery/downloads/list

沒有留言:

發佈留言