【发布时间】:2014-06-12 14:28:15
【问题描述】:
您好,我有这样的 XML 文件:
<?xml version="1.0" ?>
<songs>
<song dateplayed="2011-07-24 19:40:26">
<title>I left my heart on Europa</title>
<artist>Ship of Nomads</artist>
</song>
<song dateplayed="2011-07-24 19:27:42">
<title>Oh Ganymede</title>
<artist>Beefachanga</artist>
</song>
<song dateplayed="2011-07-24 19:23:50">
<title>Kallichore</title>
<artist>Jewitt K. Sheppard</artist>
</song>
</songs>
然后是我的 HTML 文档:
<html>
<body>
<h1>Welcome to my home page!</h1>
<p>Some text.</p>
<p>Some more text.</p>
<?php
$mysongs = simplexml_load_file('songs.xml');
echo $mysongs->song[0]->artist;?>
</body>
</html>
但是,当我开始运行页面时,我得到了这个:
通常我在这里做错了什么?看到 PHP 如何不显示艺术家,我是否需要包含一个库等? xml文件和html文件在同一个文件夹中。
【问题讨论】:
-
and then my HTML Document:在 .html 中?有你的问题:) -
做一个
view source。你可能会在那里看到所有的 php 代码。