Beispiel #1
1
<?php

require_once '../PhpQuery/PhpQuery.php';
PhpQuery::$debug = 2;
$testName = 'HTML insertion';
$doc = PhpQuery::newDocumentFile('document-types/document-utf8.xhtml');
//$doc = PhpQuery::newDocumentFile('document-types/document-utf8.html');
//$doc = PhpQuery::newDocumentFile('document-types/document-utf8.xml');
//print $doc->find('step');
print $doc->find('p');
$markup = "test<br />test<p>test p</p>";
$doc['body > p:last']->append($markup);
if ($doc['body > p:last p']->length == 1) {
    print "Test '{$testName}' PASSED :)";
} else {
    print "Test '{$testName}' <strong>FAILED</strong> !!! ";
    print $doc->htmlOuter('htmlspecialchars');
}
print "\n";
Beispiel #2
0
<?php

require_once '../PhpQuery/PhpQuery.php';
PhpQuery::$debug = true;
$testName = 'ReplaceWith';
PhpQuery::newDocumentFile('test.html')->find('p:eq(1)')->replaceWith("<p class='newTitle'>\n                        this is example title\n                    </p>");
$result = pq('p:eq(1)');
if ($result->hasClass('newTitle')) {
    print "Test '{$testName}' PASSED :)";
} else {
    print "Test '{$testName}' <strong>FAILED</strong> !!! ";
}
$result->dump();
print "\n";
$testName = 'ReplaceAll';
$testResult = 3;
PhpQuery::newDocumentFile('test.html');
pq('<div class="replacer">')->replaceAll('li:first p');
$result = pq('.replacer');
if ($result->size() == $testResult) {
    print "Test '{$testName}' PASSED :)";
} else {
    print "Test '{$testName}' <strong>FAILED</strong> !!! ";
}
$result->dump();
print "\n";