Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Tenho que fazer as noticias de um rss ser mostrada no Flash, um estagiario anterior a mim já havia feito e talz, mas comigo não está funcionando não sei por que...
Eu só copiei e colei os codigos e mudei a url do rss =/
segue abaixo os códigos
AS do Fla
>
System.security.loadPolicyFile("http://www.novacomunicacao.tv.br/rss/crossdomain.xml")
System.useCodepage = true
var carregar:Function = function () {
var texto:LoadVars = new LoadVars()
texto.onData = function(html_no_flash) {
campo_txt.condenseWhite = true
campo_txt.html = true
campo_txt.htmlText = html_no_flash
}
texto.load("[http://www.novacomunicacao.tv.br/rss/rss_terra_afazenda.asp"](http://www.novacomunicacao.tv.br/rss/rss_terra_afazenda.asp))
}
carregar()
rss_terra_afazenda.asp
>
<%
Response.Expires = -1
' =========== configuration =====================
' ##### URL to RSS Feed to display #########
URLToRSS = "http://rss.terra.com.br/0,,EI13886,00.xml"
' ##### max number of displayed items #####
MaxNumberOfItems = 1
' ##### Main template constants
MainTemplateHeader = "<body>"
MainTemplateFooter = "</body>"
' #####
' ######################################
Keyword1 = "" ' Keyword1 = "tech" - set non-empty keyword value to filter by this keyword
Keyword2 = "" ' Keyword1 = "win" - set non-empty keyword value to filter by this 2nd keyword too
' #################################
' ##### Item template.
' ##### {LINK} will be replaced with item link
' ##### {TITLE} will be replaced with item title
' ##### {DESCRIPTION} will be replaced with item description
' ##### {DATE} will be replaced with item date and time
' ##### {COMMENTSLINK} will be replaced with link to comments (if you use RSS feed from blog)
' ##### {CATEGORY} will be replaced with item category
ItemTemplate = "{TITLE}"
' ##### Error message that will be displayed if not items etc
ErrorMessage = "Ocorreu um erro durante o processo " &URLToRSS & "<BR>Por favor entre em contato com o webmaster"
' ================================================
Set xmlHttp = Server.CreateObject("MSXML2.XMLHTTP.3.0")
xmlHttp.Open "Get", URLToRSS, false
xmlHttp.Send()
RSSXML = xmlHttp.ResponseText
Set xmlDOM = Server.CreateObject("MSXML2.DomDocument.3.0")
xmlDOM.async = False
xmlDOM.validateOnParse = False
xmlDom.resolveExternals = False
If not xmlDOM.LoadXml(RSSXML) Then
ErrorMessage = "Can not load XML:" & vbCRLF & xmlDOM.parseError.reason & vbCRLF & ErrorMessage
End If
Set xmlHttp = Nothing ' clear HTTP object
Set RSSItems = xmlDOM.getElementsByTagName("item") ' collect all "items" from downloaded RSS
RSSItemsCount = RSSItems.Length-1
' if not <item>..</item> entries, then try to get <entry>..</entry>
if RSSItemsCount = -1 Then
Set RSSItems = xmlDOM.getElementsByTagName("entry") ' collect all "entry" (atom format) from downloaded RSS
RSSItemsCount = RSSItems.Length-1
End If
Set xmlDOM = Nothing ' clear XML
' writing Header
if RSSItemsCount > 0 then
Response.Write MainTemplateHeader
End If
j = -1
For i = 0 To RSSItemsCount
Set RSSItem = RSSItems.Item(i)
for each child in RSSItem.childNodes
Select case lcase(child.nodeName)
case "title"
RSStitle = child.text
case "link"
If RSSLink = "" Then
If child.Attributes.length>0 Then
RSSLink = child.GetAttribute("href")
if (RSSLink <> "") Then
if child.GetAttribute("rel") <> "alternate" Then
RSSLink = ""
End If
End If
End If ' if has attributes
If RSSLink = "" Then
RSSlink = child.text
End If
End If
case "description"
RSSdescription = child.text
case "content" ' atom format
RSSdescription = child.text
case "published"' atom format
RSSDate = child.text
case "pubdate"
RSSDate = child.text
case "comments"
RSSCommentsLink = child.text
case "category"
Set CategoryItems = RSSItem.getElementsByTagName("category")
RSSCategory = ""
for each categoryitem in CategoryItems
if RSSCategory <> "" Then
RSSCategory = RSSCategory & ", "
End If
RSSCategory = RSSCategory & categoryitem.text
Next
End Select
next
' now check filter
If (InStr(RSSTitle,Keyword1)>0) or (InStr(RSSTitle,Keyword2)>0) or (InStr(RSSDescription,Keyword1)>0) or (InStr(RSSDescription,Keyword2)>0) then
j = J+1
if J<MaxNumberOfItems then
ItemContent = Replace(ItemTemplate,"{LINK}",RSSlink)
ItemContent = Replace(ItemContent,"{TITLE}",RSSTitle)
ItemContent = Replace(ItemContent,"{DATE}",RSSDate)
ItemContent = Replace(ItemContent,"{COMMENTSLINK}",RSSCommentsLink)
ItemContent = Replace(ItemContent,"{CATEGORY}",RSSCategory)
Response.Write Replace(ItemContent,"{DESCRIPTION}",RSSDescription)
ItemContent = ""
RSSLink = ""
End if
End If
Next
' writing Footer
if RSSItemsCount > 0 then
Response.Write MainTemplateFooter
else
Response.Write ErrorMessage
End If
' Response.End ' uncomment this for use in on-the-fly output
%>
crossdomain.xml
>
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>
Não mexi em nada a não ser onde poe a url do rss no arquivo asp e o nome a url do arquivo asp no flash no resto ta td igual
onde o outro estagiario fez esses códigos ele da as noticias normalmente, nos meus aparece a seguinte mensagem "Can not load XML: An invalid character was found in text content. Ocorreu um erro durante o processo http://rss.terra.com.br/0,,El13886,00.xml"
pode ser uma bobeirinha, mas eu não entendo quase nada de AS e exatamente nada de XML e ASP =/
Se puderem me ajudar eu de já agradeço e muito.
Carregando comentários...