[php怎么取读xml文件内容]php怎么取读xml文件

更新时间:2015-06-10    来源:Dom教程    手机版     字体:

【www.bbyears.com--Dom教程】


$doc = new DOMDocument();
$doc->load( "books.xml" );

$books = $doc->getElementsByTagName( "book" );
foreach( $books as $book )
{
$authors = $book->getElementsByTagName( "author" );
$author = $authors->item(0)->nodeValue;

$publishers = $book->getElementsByTagName( "publisher" );
$publisher = $publishers->item(0)->nodeValue;

$titles = $book->getElementsByTagName( "title" );
$title = $titles->item(0)->nodeValue;

echo "$title - $author - $publishern";
}
?>

本文来源:http://www.bbyears.com/wangyezhizuo/15731.html

猜你感兴趣