PHP code example of deimos / qparser

1. Go to this page and download the library: Download deimos/qparser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

deimos / qparser example snippets


$html = <<<HTML
<div id="article" class="block large">
  <h2>Article Name</h2>
  <p>Contents of article</p>
  <ul>
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
    <li>Four</li>
    <li><a href="#">Five</a></li>
  </ul>
</div>
HTML;

$qParser = new \Deimos\QParser($html);

var_dump($qParser->find('div#article.large'));
var_dump($qParser->find('div > h2:contains(Article)'));
var_dump($qParser->find('div p + ul'));
var_dump($qParser->find('ul > li:first-child'));
var_dump($qParser->find('ul > li ~ li'));
var_dump($qParser->find('ul > li:last-child'));
var_dump($qParser->find('li a[href=#]'));