Exemplo n.º 1
0
--TEST--
Jsoup test #2
--FILE--
<?php 
use php\io\Stream;
use php\jsoup\Jsoup;
$source = Stream::of('php://memory', 'w+');
$source->write('<a>foobar</a>');
$source->seek(0);
$doc = Jsoup::parse($source, 'UTF-8', 'examle.com');
var_dump($doc->select('a')->text());
?>
--EXPECT--
string(6) "foobar"
Exemplo n.º 2
0
--TEST--
Jsoup test #1
--FILE--
<?php 
use php\jsoup\Jsoup;
$doc = Jsoup::parseText('<a href="www" id="100500">foobar</a>');
$element = $doc->select('a')->first();
var_dump($element->text());
var_dump($element->tagName());
var_dump($element->nodeName());
var_dump($element->attr('href'));
$element->attr('href', 'www_modified');
var_dump($element->attr('href'));
var_dump($element->html());
var_dump($element->id());
?>
--EXPECT--
string(6) "foobar"
string(1) "a"
string(1) "a"
string(3) "www"
string(12) "www_modified"
string(6) "foobar"
string(6) "100500"