HTML; $dom->load($str); $es = $dom->find('img'); assert(count($es)==3); assert($es[0]->src=='src0'); assert($es[1]->src=='src1'); assert($es[2]->src=='src2'); assert($es[0]->innertext==''); assert($es[1]->innertext==''); assert($es[2]->innertext==''); assert($es[0]->outertext==''); assert($es[1]->outertext==''); assert($es[2]->outertext==''); assert($dom->find('img', 0)->src=='src0'); assert($dom->find('img', 1)->src=='src1'); assert($dom->find('img', 2)->src=='src2'); assert($dom->find('img', 3)===null); assert($dom->find('img', 99)===null); assert($dom->save()==$str); // ----------------------------------------------------------------------------- // test error tag $str = <<

p1

HTML; $dom = str_get_html($str); $es = $dom->find('img'); assert(count($es)==3); assert($es[0]->src=='src0'); assert($es[1]->src=='src1'); assert($es[2]->src=='src2'); $es = $dom->find('p'); assert($es[0]->innertext=='p1'); assert($dom==$str); // ----------------------------------------------------------------------------- // tear down $dom->clear(); unset($dom); ?>