我正在尝试根据Laracasts教程编写XML馈送器。我需要添加博客帖子缩略图作为媒体元素,但我在媒体开头出现错误:内容
XML Parsing Error: prefix not bound to a namespace
<media:content url="https:/sirtcantalilar.com/uploads/img/posts/2/Paris_train_station.jpg">
--------------^
我的XML视图就像Laracast:
{{ '<?xml version="1.0" encoding="utf-8" ?>' }}
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Sirtcantalilar Topluluğu</title>
<subtitle></subtitle>
<updated>{{ Carbon\Carbon::now()->toATOMString() }}</updated>
<author>
<name></name>
</author>
<id>tag:sirtcantalilar.com, {{date('Y')}}:/feed</id>
@foreach($posts as $post)
<entry>
<author>
<name>{{$post->author->name}}</name>
</author>
<title>{{ $post->title }}</title>
<link> {{ URL::route('view-post', $post->slug) }}</link>
<id>{{ post_tag_uri($post)}}</id>
<summary>{{$post->minicontent}}</summary>
<category term="Blog"/>
<content type="html"><![CDATA[{{$post->content}}]]></content>
<media:content url="https:/sirtcantalilar.com/uploads/img/posts/{{$post->id}}/{{$post->thumbnail->name}}">
<media:thumbnail url="https:/sirtcantalilar.com/uploads/img/posts/{{$post->id}}/thumb-{{$post->thumbnail->name}}" type="image/jpeg"/>
<media:credit>Image{{$post->id}} attribution</media:credit>
<media:title>Image{{$post->id}} caption</media:title>
<media:text>Image{{$post->id}} alt-text</media:text>
</media:content>
</entry>
@endforeach
</feed>
你可以帮帮我吗?
答案 0 :(得分:2)
Atom Feed中的media
前缀应引用MediaRSS namespace。您可以使用xmlns="http://www.w3.org/2005/Atom"
将默认命名空间定义为Atom,但不要定义media
前缀。您需要添加定义..
<feed
xmlns="http://www.w3.org/2005/Atom"
xmlns:media="http://search.yahoo.com/mrss/">