php - 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';
我尝试更改标题类型,但也没有任何区别。我会很感激一些帮助。
解决方案
推荐阅读
- android - 在新的开发者控制台中选择/上传 Obb 文件
- ios - Xcode 12.1,禁用捆绑标识符
领域,颤振应用 - sas - 如何标准化 SAS 数据集中的所有数字列?
- python - 为什么这个 WHILE 循环没有结束?[Python]
- node.js - 如何将前缀值设置为大写和小写?(不和谐.js)
- apache-kafka - Kafka Spring Cloud Stream批量消费 - 无法将类转换为消息
- python - 用随机数字/大写/小写Python替换字符串中的多个字符
- r - 检查 group_by 中的条件以提取项目列表
- ios - 如何使用 Xcode 中的用户默认值将图像保存在视图控制器中?
- imagemagick - 如何使用 ImageMagick 转换工具水平合并两个半图像,创建拆分视图?