在没有看到您的代码的情况下,现在可以告诉您出了什么问题。无论如何,您指出的 XML 是有效的,这是一个工作示例,用于检索第一个项目节点标题并从您提供的 URL 链接到 XML。
为了减少这里的粘贴大小,我稍微格式化了 XML,只保留了 2 个项目节点。请参阅http://codepad.viper-7.com/3UPARI中的完整工作示例。
<?php
$xml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>Latest CraftBukkit artifacts for Recommended Build</title>
<link>http://dl.bukkit.org/downloads/craftbukkit/list/rb/</link>
<description>The latest "CraftBukkit" artifacts for Recommended Build</description>
<atom:link href="http://dl.bukkit.org/downloads/craftbukkit/feeds/latest-rb.rss" rel="self" />
<language>en-us</language>
<lastBuildDate>Thu, 31 Jan 2013 04:37:54 +0000</lastBuildDate>
<item>
<title>Recommended Build for CraftBukkit: 1.4.7-R1.0 (build 2624)</title>
<link>http://dl.bukkit.org/downloads/craftbukkit/view/01845_1.4.7-R1.0/</link>
<description><p>This new version is 12.0 MB big.</p></description>
<pubDate>Thu, 31 Jan 2013 04:37:54 +0000</pubDate>
<guid>http://dl.bukkit.org/downloads/craftbukkit/view/01845_1.4.7-R1.0/</guid>
</item>
<item>
<title>Recommended Build for CraftBukkit: 1.4.5-R1.0 (build 2543)</title>
<link>http://dl.bukkit.org/downloads/craftbukkit/view/01707_1.4.5-R1.0/</link>
<description><p>This new version is 11.9 MB big.</p></description>
<pubDate>Wed, 19 Dec 2012 11:14:13 +0000</pubDate>
<guid>http://dl.bukkit.org/downloads/craftbukkit/view/01707_1.4.5-R1.0/</guid>
</item>
</channel>
</rss>
XML;
$sxe = new SimpleXMLElement($xml);
echo "Title: {$sxe->channel->item[0]->title}\n";
echo "Link: {$sxe->channel->item[0]->link}\n";
输出
Title: Recommended Build for CraftBukkit: 1.4.7-R1.0 (build 2624)
Link: http://dl.bukkit.org/downloads/craftbukkit/view/01845_1.4.7-R1.0/