get_xml.php文件
<?php
//获取XML 方法
header('Content-type:text/html; charset=utf-8');
$doc = new DOMDocument(); //实例化DOM组件
$doc->load('get_xml.xml'); //载入XML文件
$book = $doc->getElementsByTagName('book'); //获取文件标签名
$title = $doc->getElementsByTagName('title');
foreach ($title as $key => $value) {
echo $value->nodeValue."<br>"; //输出标签内容
}
?>
get_xml.xml文件
<?xml version="1.0" encoding="utf-8"?>
<bookstore>
<book>
<title>
php中文读书网
</title>
<title>
CSS读书网
</title>
</book>
</bookstore>