1--TEST-- 2SimpleXML [interop]: simplexml_import_dom 3--SKIPIF-- 4<?php if (!extension_loaded("simplexml")) die("skip"); ?> 5<?php if (!extension_loaded("dom")) die("skip dom extension not loaded"); ?> 6--FILE-- 7<?php 8$dom = new domDocument; 9$dom->load(__DIR__."/book.xml"); 10if(!$dom) { 11 echo "Error while parsing the document\n"; 12 exit; 13} 14$s = simplexml_import_dom($dom); 15$books = $s->book; 16foreach ($books as $book) { 17 echo "{$book->title} was written by {$book->author}\n"; 18} 19?> 20--EXPECT-- 21The Grapes of Wrath was written by John Steinbeck 22The Pearl was written by John Steinbeck 23