首页 > 解决方案 > XML 结构破坏提要产生错误文档为空

问题描述

我需要一些指导,请。我一直在尝试实现一个 XML 结构,然后通过 PHP 对其进行解析以获得最终结果。这个系统不是我设置的,而是别人设置的,所以我有点迷茫。

在添加这两个标签之前,结构似乎很好

  <videoItems> <videoItem>  </videoItem>  </videoItems> 

然后我收到错误消息:“此页面包含以下错误:第 1 行第 1 列的错误:文档为空下面是页面的呈现直到第一个错误。” 如果我删除这些标签,提要工作正常,通过 PHP 解析就好了。

这是结构:

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:msn="http://microsoft.com/msnrss" xmlns:dcterms="http://purl.org/dc/terms/">
<channel><source>Media</source><description>Video feed</description>
<item>
<title>***headline***</title>
<videoItems>
<videoItem>
<media:content url="***videoURL***" type="video/mp4"></media:content>
<videoFiletype>video/mp4</videoFiletype>
<videoDesc>***abstract***</videoDesc>
<videoLang>EN</videoLang>
<videoCover> <media:thumbnail height="650" width="1000" type="image/jpeg" url="***img1***"/></videoCover>
<media:keywords>
<![CDATA[ ***people*** ]]>
</media:keywords>
<videoTags>
<tag>***people***,***location***,***brands***</tag>
</videoTags>
</videoItem>
</videoItems>
<pubDate>***story_publish_ISO***</pubDate>
</item>
</channel>
</rss>

这是解析 MRSS 的 PHP 部分:

                      case 'mrss':

                        foreach ($items as $key => $item) {
                            $vidFile = $item->vurl;

                            $vidFilename = $this->rootPath . '/' . $target->filePath . '/' . $vidFile;

                            if ($this->devMode == true) {
                                $fileExists = true;
                                $item->vidfs = 12345;
                            } else {
                                $fileExists = file_exists($vidFilename);
                                if (!$fileExists) {
                                    $this->saveFile($this->sourceHost . '/' . $item->vurl, $vidFilename);
                                    $fileExists = file_exists($vidFilename);

                                    if ($fileExists)
                                        $item->vidfs = filesize($vidFilename);
                                }
                            }

                            if ($fileExists) {
                                $item->vidfn = 'http://' . $_SERVER['HTTP_HOST'] . $target->fileUrlRoot . '/' . $vidFile;
                                $data = str_replace($item->find, $item->vidfn, $data);

                            } else {
                                $this->errors[] = 'Missing Video ' . $vidFile;
                            }
                        }

                        if (isset($target->processContent)) {
                            $pc = $target->processContent;
                            $data = $pc($data);
                        }

                        $this->setContent($data);

                        break;
                    default:
                        if ($this->debug)
                            $this->debugging[] = 'Items Processing for ' . $details->expected . " is missing";

                        $this->errors[] = 'Items Processing is not configured';
                }

                return true;

            } else {
                $this->errors[] = 'Could not find any feed Items';

我尝试更改标题类型,但也没有任何区别。我会很感激一些帮助。

标签: phpxmlrssfeed

解决方案


推荐阅读