find('p[rel]:first') ->attr('rel', $expected); if ($result->attr('rel') == $expected) print "Test '{$testName}' passed :)"; else print "Test '{$testName}' FAILED !!!"; print "\n"; $testName = 'Attribute change in iteration'; $expected = 'new attr value'; $doc = phpQuery::newDocumentFile('test.html'); foreach($doc['p[rel]:first'] as $p) pq($p)->attr('rel', $expected); if ($doc['p[rel]:first']->attr('rel') == $expected) print "Test '{$testName}' passed :)"; else print "Test '{$testName}' FAILED !!!"; print "\n";