我有一个脚本,它生成一个带有 ColdFusion 及其CFFeed
标签的 xml 文件。除了图像,它工作得很好。我知道您必须使用封装图像CDATA
才能显示它。我不确定我是否设置正确,因为图像没有显示在我的 Google 阅读器/Feedly 提要中。这是代码:
<cfquery datasource="data" name="queryT">
SELECT *
FROM qTable
WHERE ...
ORDER BY...
</cfquery>
<cfset RssStruct = StructNew() />
<cfset RssStruct.link = "https://www.url.com" />
<cfset RssStruct.title = "sitename" />
<cfset RssStruct.description = "url Blog" />
<cfset RssStruct.image.url = 'https://www.url.com/assets/img/ns.png' />
<cfset RssStruct.image.title = 'Site Name' />
<cfset RssStruct.image.link = 'https://www.url.com' />
<cfset RssStruct.pubDate = Now() />
<cfset RssStruct.version = "rss_2.0" />
<cfset RssStruct.item = ArrayNew(1) />
<cfset threadlist = "">
<cfset index = 1>
<cfloop query="queryT">
<cfif listcontains( threadlist , '#id#' ) eq 0>
<cfset threadlist = ListAppend(threadlist, '#id#')>
<!--- Here let's clean up and ensure that all values are XML Compliant --->
<cfset RssStruct.item[index] = StructNew() />
<cfset RssStruct.item[index].guid = structNew() />
<cfset RssStruct.item[index].guid.isPermaLink ="YES" />
<cfset RssStruct.item[index].guid.value = 'https://www.url.com/page.cfm?itemid=#queryT.id#' />
<cfset RssStruct.item[index].pubDate = createDate(year(Posted), month(Posted), day(Posted)) />
<cfset RssStruct.item[index].title = xmlFormat(#title#) />
<cfset RssStruct.item[index].Body = xmlFormat(#Body#) />
<cfset RssStruct.item[index].description = StructNew() />
<cfset RssStruct.item[index].description.value = '<![CDATA[ <img src="https://www.url.com/assets/Photos/photo/#id#.jpg"> #body# ]]>' />
<cfset RssStruct.item[index].link = 'https://www.url.com/page.cfm?item=#queryT.id#' /><br>
<cfset index = index + 1>
</cfif>
</cfloop>
<!--- Generate the feed and save it to a file and variable. --->
<cffeed action="create" name="#RssStruct#" overwrite="true" xmlVar="myXML" outputFile = "Feed.xml" />`