是的,我正在一个有几个不同 RSS 提要的网站上工作。我的问题是我的一个提要工作得很好,但是第二个提要(基于几乎相同的代码)失败了,我不知道为什么。
这是有效的代码:
<!--- Get the feed data as a query from the orders table. --->
<cfquery name="getNews" datasource="#DSN#">
SELECT * FROM NEWS2
WHERE STATUS = 1
ORDER BY rdate DESC
</cfquery>
<cfset myStruct = StructNew() />
<cfset mystruct.link = "http://noobzilla.net" />
<cfset myStruct.title = "Noobzilla News" />
<cfset mystruct.description = "Programming Related Site Reviews" />
<cfset mystruct.pubDate = Now() />
<cfset mystruct.version = "rss_2.0" />
<cfset myStruct.item = ArrayNew(1) />
<cfloop query="getNews">
<cfset myStruct.item[currentRow] = StructNew() />
<cfset myStruct.item[currentRow].guid = structNew() />
<cfset myStruct.item[currentRow].guid.isPermaLink="YES" />
<cfset myStruct.item[currentRow].guid.value = 'http://noobzilla.net/news-detail.cfm?id=#id#' />
<cfset myStruct.item[currentRow].pubDate = "#DateFormat(getNews.rdate, "mm/dd/yyyy")#" />
<!---<cfset myStruct.item[currentRow].title = xmlFormat(title) />--->
<cfset myStruct.item[currentRow].title = #title# />
<cfset myStruct.item[currentRow].description = StructNew() />
<!---<cfset myStruct.item[currentRow].description.value = xmlFormat(#info#) />--->
<cfset myStruct.item[currentRow].description.value = '#Left(info, 250)#...' />
<cfset myStruct.item[currentRow].link = 'http://noobzilla.net/news-detail.cfm?id=#id#' />
</cfloop>
<!--- Generate the feed and save it to a variable. --->
<cffeed action="create" name="#myStruct#" overwrite="true" xmlVar="myXML" />
上面的代码效果很好。现在这是我的第二个文件中的代码(您可以看到它几乎相同,只是使用了不同的表):
<!--- Get the feed data as a query from the orders table. --->
<cfquery name="getNews" datasource="#DSN#">
SELECT * FROM NEWS
WHERE STATUS = 1
ORDER BY rdate DESC
</cfquery>
<cfset myStruct = StructNew() />
<cfset mystruct.link = "http://noobzilla.net" />
<cfset myStruct.title = "IDE Reviews" />
<cfset mystruct.description = "IDE and SDK Reviews" />
<cfset mystruct.pubDate = Now() />
<cfset mystruct.version = "rss_2.0" />
<cfset myStruct.item = ArrayNew(1) />
<cfloop query="getNews">
<cfset myStruct.item[currentRow] = StructNew() />
<cfset myStruct.item[currentRow].guid = structNew() />
<cfset myStruct.item[currentRow].guid.isPermaLink="YES" />
<cfset myStruct.item[currentRow].guid.value = 'http://noobzilla.net/news-detail2.cfm?id=#id#' />
<cfset myStruct.item[currentRow].pubDate = "#DateFormat(getNews.rdate, "mm/dd/yyyy")#" />
<cfset myStruct.item[currentRow].title = #title# />
<cfset myStruct.item[currentRow].description = StructNew() />
<cfset myStruct.item[currentRow].description.value = '#Left(info, 250)#...' />
<cfset myStruct.item[currentRow].link = 'http://noobzilla.net/news-detail2.cfm?id=#id#' />
</cfloop>
<!--- Generate the feed and save it to a variable. --->
<cffeed action="create" name="#myStruct#" overwrite="true" xmlVar="myXML" />
第二组代码生成以下错误:
解析 pubDate 中指定的日期时出错。无法将 pubDate 转换为日期。