HTML; $dom->load($str); $e = $dom->find('hr', 0); $e->id= 'foo'; assert($e->outertext=='
'); // ----------------------------------------------- $str = << HTML; $dom->load($str); $e = $dom->find('hr', 0); $e->id= 'foo'; assert($e->outertext=='
'); // ----------------------------------------------- $str = << HTML; $dom->load($str); $e = $dom->find('hr', 0); $e->id= 'foo'; assert($e->outertext=='
'); // ----------------------------------------------- $str = << HTML; $dom->load($str); $e = $dom->find('hr', 0); $e->id= 'foo'; $e->class = 'bar'; assert($e->outertext=='
'); // ----------------------------------------------- $str = << HTML; $dom->load($str); $e = $dom->find('hr', 0); $e->id= 'foo'; $e->class = 'bar'; assert($e->outertext=='
'); // ----------------------------------------------- $str = << HTML; $dom->load($str); $e = $dom->find('hr', 0); $e->id= 'foo'; $e->class = 'bar'; assert($e->outertext=='
'); // ----------------------------------------------- $str = << HTML; $dom->load($str); $e = $dom->find('hr', 0); $e->class = 'bar'; assert($e->outertext=='
'); // ----------------------------------------------- $str = << HTML; $dom->load($str); $e = $dom->find('hr', 0); $e->class = 'bar'; assert($e->outertext=='
'); // ----------------------------------------------- $str = << HTML; $dom->load($str); $e = $dom->find('hr', 0); $e->class = 'bar'; assert($e->outertext=='
'); // ----------------------------------------------- $str = << HTML; $dom->load($str); $e = $dom->find('nobr', 0); assert($e->outertext==''); // ----------------------------------------------------------------------------- // optional closing tags test $str = << <.b> HTML; $dom = str_get_html($str); assert($dom->find('body', 0)->outertext==$str); // ----------------------------------------------- $str = << foo foo2 HTML; $dom = str_get_html($str); assert($dom==$str); assert($dom->find('html body a', 1)->innertext=='foo2'); // ----------------------------------------------- $str = <<find('html a', 1)===null); //assert($dom->find('html a', 1)->innertext=='foo2'); // ----------------------------------------------- $str = <<
HTML; $dom = str_get_html($str); assert($dom==$str); assert($dom->find('body', 0)->outertext==$str); // ----------------------------------------------- $str = <<
HTML; $dom = str_get_html($str); assert($dom->find('body', 0)->outertext==$str); // ----------------------------------------------- $str = << aa bb HTML; $dom = str_get_html($str); assert($dom==$str); // ----------------------------------------------- $str = << 123 HTML; $dom = str_get_html($str); assert(count($dom->find('td'))==3); assert($dom->find('td', 0)->innertext=='1'); assert($dom->find('td', 0)->outertext=='1'); assert($dom->find('td', 1)->innertext=='2'); assert($dom->find('td', 1)->outertext=='2'); assert($dom->find('td', 2)->innertext=="3\r\n"); assert($dom->find('td', 2)->outertext=="3\r\n"); // ----------------------------------------------- $str = << 1 2 3 HTML; $dom = str_get_html($str); assert(count($dom->find('tr td'))==3); // ----------------------------------------------- $str = << 111213 213243 HTML; $dom = str_get_html($str); assert(count($dom->find('tr'))==2); assert(count($dom->find('tr td'))==6); assert($dom->find('tr', 1)->outertext=="213243\r\n"); assert($dom->find('tr', 1)->innertext=="213243\r\n"); assert($dom->find('tr', 1)->plaintext=="213243\r\n"); // ----------------------------------------------- $str = <<1

2

3 HTML; $dom = str_get_html($str); assert(count($dom->find('p'))==3); assert($dom->find('p', 0)->innertext=="1\r\n"); assert($dom->find('p', 0)->outertext=="

1\r\n"); assert($dom->find('p', 1)->innertext=="2"); assert($dom->find('p', 1)->outertext=="

2

"); assert($dom->find('p', 2)->innertext=="3"); assert($dom->find('p', 2)->outertext=="

3"); // ----------------------------------------------- $str = <<1 2 3 HTML; $dom = str_get_html($str); assert(count($dom->find('nobr'))==3); assert($dom->find('nobr', 0)->innertext=="1\r\n"); assert($dom->find('nobr', 0)->outertext=="1\r\n"); assert($dom->find('nobr', 1)->innertext=="2"); assert($dom->find('nobr', 1)->outertext=="2"); assert($dom->find('nobr', 2)->innertext=="3"); assert($dom->find('nobr', 2)->outertext=="3"); // ----------------------------------------------- $str = <<

1
2
3
4 HTML; $dom = str_get_html($str); assert(count($dom->find('dt'))==2); assert(count($dom->find('dd'))==2); assert($dom->find('dt', 0)->innertext=="1"); assert($dom->find('dt', 0)->outertext=="
1"); assert($dom->find('dt', 1)->innertext=="3"); assert($dom->find('dt', 1)->outertext=="
3"); assert($dom->find('dd', 0)->innertext=="2"); assert($dom->find('dd', 0)->outertext=="
2"); assert($dom->find('dd', 1)->innertext=="4"); assert($dom->find('dd', 1)->outertext=="
4"); // ----------------------------------------------- $str = <<
11
12
13
14
21
22
23
24
HTML; $dom = str_get_html($str); assert(count($dom->find('#dl1 dt'))==2); assert(count($dom->find('#dl2 dd'))==2); assert($dom->find('dl', 0)->innertext=="
11
12
13
14"); assert($dom->find('dl', 1)->innertext=="
21
22
23
24"); // ----------------------------------------------- $str = <<
  • 1
  • 2
    • 3
    • 4
    HTML; $dom = str_get_html($str); assert(count($dom->find('ul[id=ul1] li'))==2); // ----------------------------------------------------------------------------- // invalid test $str = <<
  • HTML; $dom->load($str); assert(count($dom->find('img'))==2); assert(count($dom->find('img'))==2); assert($dom==$str); // ----------------------------------------------- $str = <<
    HTML; $dom->load($str); assert(count($dom->find('span'))==2); assert(count($dom->find('div'))==2); assert($dom==$str); // ----------------------------------------------- $str = <<
    HTML; $dom->load($str); assert(count($dom->find('span'))==3); assert(count($dom->find('div'))==2); assert($dom==$str); // ----------------------------------------------- $str = << HTML; $dom->load($str); assert(count($dom->find('ul'))==2); assert(count($dom->find('ul ul'))==1); assert(count($dom->find('li'))==1); assert(count($dom->find('a'))==1); assert($dom==$str); // ----------------------------------------------- $str = <<
    HTML; $dom->load($str); assert(count($dom->find('td'))==1); assert(count($dom->find('div'))==1); assert(count($dom->find('td div'))==1); assert($dom==$str); // ----------------------------------------------- $str = <<
    HTML; $dom->load($str); assert(count($dom->find('td'))==1); assert(count($dom->find('div'))==1); assert(count($dom->find('td div'))==1); assert($dom==$str); // ----------------------------------------------- $str = <<
    HTML; $dom->load($str); assert(count($dom->find('td'))==1); assert(count($dom->find('div'))==1); assert(count($dom->find('td div'))==1); assert($dom==$str); // ----------------------------------------------- $str = << foobarimportant
    HTML; $dom->load($str); assert(count($dom->find('table span'))===1); assert($dom->find('table span', 0)->innertext==='bar'); assert($dom==$str); // ----------------------------------------------- $str = <<
    foo
    HTML; $dom->load($str); assert(count($dom->find('td div font b'))==1); assert($dom==$str); // ----------------------------------------------- $str = << ... then slow into 287 (hanover0...more volume between 202 & 53 (parsippany) ...then sluggish in spots out to dover chester road (randolph) ..then traffic light delays out to route 46 (roxbury) /eb slow into 202 (morris plains) & again into 287 (hanover) . 52 HTML; $dom->load($str); assert(count($dom->find('span td'))==0); assert($dom==$str); // ----------------------------------------------------------------------------- // invalid '<' // ----------------------------------------------- $str = <<test :1 gram but <5 grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but <5 grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but <5 grams'); assert($dom==$str); $str = <<test :1 gram but<5 grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but<5 grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but<5 grams'); assert($dom==$str); $str = <<test :1 gram but< 5 grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but< 5 grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but< 5 grams'); assert($dom==$str); $str = <<test :1 gram but < 5 grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but < 5 grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but < 5 grams'); assert($dom==$str); $str = <<test :1 gram but 5< grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but 5< grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but 5< grams'); assert($dom==$str); $str = <<test :1 gram but 5 < grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but 5 < grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 < grams'); assert($dom==$str); $str = <<test :1 gram but 5 HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but 5 find('td', 0)->plaintext==='test :1 gram but 5 test :1 gram but 5< grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but 5< grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but 5< grams'); assert($dom==$str); $str = <<test :1 gram but5< grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but5< grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but5< grams'); assert($dom==$str); $str = <<test :1 gram but 5 HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but 5 find('td', 0)->plaintext==='test :1 gram but 5 test :1 gram but 5 HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but 5find('td', 0)->plaintext==='test :1 gram but 5test :1 gram but 5 HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but 5 find('td', 0)->plaintext==='test :1 gram but 5 ' // ----------------------------------------------- $str = <<test :1 gram but >5 grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but >5 grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but >5 grams'); assert($dom==$str); $str = <<test :1 gram but>5 grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but>5 grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but>5 grams'); assert($dom==$str); $str = <<test :1 gram but> 5 grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but> 5 grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but> 5 grams'); assert($dom==$str); $str = <<test :1 gram but > 5 grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but > 5 grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but > 5 grams'); assert($dom==$str); $str = <<test :1 gram but 5> grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but 5> grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but 5> grams'); assert($dom==$str); $str = <<test :1 gram but 5 > grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but 5 > grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 > grams'); assert($dom==$str); $str = <<test :1 gram but 5 >grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but 5 >grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 >grams'); assert($dom==$str); // ----------------------------------------------- $str = <<test :1 gram but 5> grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but 5> grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but 5> grams'); assert($dom==$str); $str = <<test :1 gram but5> grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but5> grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but5> grams'); assert($dom==$str); $str = <<test :1 gram but 5 >grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but 5 >grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 >grams'); assert($dom==$str); $str = <<test :1 gram but 5>grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but 5>grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but 5>grams'); assert($dom==$str); $str = <<test :1 gram but 5 >grams HTML; $dom->load($str); assert($dom->find('td', 0)->innertext==='test :1 gram but 5 >grams'); assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 >grams'); assert($dom==$str); // ----------------------------------------------------------------------------- // BAD HTML test $str = <<http://www.oeb.harvard.edu/faculty/girguis/">.

    HTML; $dom->load($str); // ----------------------------------------------- $str = <<http://www.oeb.harvard.edu/faculty/girguis/"> HTML; $dom->load($str); // ----------------------------------------------- $str = <<""'''"'" ' HTML; $dom->load($str); // ----------------------------------------------------------------------------- // tear down $dom->clear(); unset($dom); ?>