RSS ColdFusion – CFC

table.cfdump_wddx, table.cfdump_xml, table.cfdump_struct, table.cfdump_array, table.cfdump_query, table.cfdump_cfc, table.cfdump_object, table.cfdump_binary, table.cfdump_udf, table.cfdump_udfbody, table.cfdump_udfarguments {font-size: xx-small; font-family: verdana, arial, helvetica, sans-serif; cell-spacing: 2px;} table.cfdump_wddx th, table.cfdump_xml th, table.cfdump_struct th, table.cfdump_array th, table.cfdump_query th, table.cfdump_cfc th, table.cfdump_object th, table.cfdump_binary th, table.cfdump_udf th, table.cfdump_udfbody th, table.cfdump_udfarguments th {text-align: left; color: white; padding: 5px;} table.cfdump_wddx td, table.cfdump_xml td, table.cfdump_struct td, table.cfdump_array td, table.cfdump_query td, table.cfdump_cfc td, table.cfdump_object td, table.cfdump_binary td, table.cfdump_udf td, table.cfdump_udfbody td, table.cfdump_udfarguments td {padding: 3px; background-color: #ffffff; vertical-align : top;} table.cfdump_wddx {background-color: #000000;} table.cfdump_wddx th.wddx {background-color: #444444;} table.cfdump_xml {background-color: #888888;} table.cfdump_xml th.xml {background-color: #aaaaaa;} table.cfdump_xml td.xml {background-color: #dddddd;} table.cfdump_struct {background-color: #0000cc ;} table.cfdump_struct th.struct {background-color: #4444cc ;} table.cfdump_struct td.struct {background-color: #ccddff;} table.cfdump_array {background-color: #006600 ;} table.cfdump_array th.array {background-color: #009900 ;} table.cfdump_array td.array {background-color: #ccffcc ;} table.cfdump_query {background-color: #884488 ;} table.cfdump_query th.query {background-color: #aa66aa ;} table.cfdump_query td.query {background-color: #ffddff ;} table.cfdump_cfc {background-color: #ff0000;} table.cfdump_cfc th.cfc{background-color: #ff4444;} table.cfdump_cfc td.cfc {background-color: #ffcccc;} table.cfdump_object {background-color : #ff0000;} table.cfdump_object th.object{background-color: #ff4444;} table.cfdump_binary {background-color : #eebb00;} table.cfdump_binary th.binary {background-color: #ffcc44;} table.cfdump_binary td {font-size: x-small;} table.cfdump_udf {background-color: #aa4400;} table.cfdump_udf th.udf {background-color: #cc6600;} table.cfdump_udfarguments {background-color: #dddddd; cell-spacing: 3;} table.cfdump_udfarguments th {background-color: #eeeeee; color: #000000;}

Introdução

O RSS primeiro recebeu a nomemclatura RDF Site Summary (Sumário RDF do Site ), depois Rich Site Summary (Sumário Rico do Site) , e em seguida Really Simple Syndication (Distribuidor Realmente Simples), esta última é a forma mais encontrada para definição da sigla.

Criado com a finalidade de prover dados/informações a aplicações remotas, foi rapidamente absorvido pelas agências de notícias, e sua importância foi reconhecida com a mesma velocidade, sites como mxstudio, blogs, grupos de discussão, entre outros passaram a adota-lo a partir do momento que foram surgindo os leitores de RSS (Read Feed), deste ponto em diante ele não tem parado de expandir-se e ser divulgado.

O leitor de RSS, fazendo uma analogia a vida real, é uma pequena banca de jornais (jornaleiro) que exibe inumeras publicações de categorias distintas, com um breve resumo na capa de cada publicação. E para que isto aconteça basta que seja informado o endereço internet do RSS que deseja colocar na sua banca particular.

Alguns exemplos de leitores de RSS:
- O browser Opera, a partir da versão 7.5.
- O browser Firefox, a partir da versão 1.0.
- O cliente de e-mail MS Outlook, com auxílio do plug-in InstantaNews, ou IntraVNews.
- O cliente de e-mail Thunderbird.
- A plicação desktop (Linux) Liferea.
- A plicação desktop (Java) ThinFeeder.
- A plicação desktop (win32) Newzcrawler, que executa leitura em vários tipos de RSS.
- Aplicação para portáteis, Pocket Feed.

W3C e RSS

Foi preciso criar um padrão para que todas as aplicações soubessem onde procurar a informação, e o responsável por esta padronização foi o W3C, que é um consórcio responsável por padronizar as linguagens para todos os navegadores.

O W3C o classifica como Resource Description Framework (Estrutura de Descrição do Recurso) .
As várias mudanças na nomemclatura deveu-se a rápida absorção por aplicações e sites, exigindo deste órgão o aperfeiçoamento da estrutura que é baseada na linguagem XML (Extensible Markup Language), a versão mais utilizada ainda é a 2.0, e sua evolução não parou e criou um formato mais elaborado nomeado por Atom Syndication Format (Formato de Distribuição Atom).
XML.org é o local mais atualizado em informações sobre essa linguagem.

RSS 2.0

Agora já sabemos que RSS não é ninguém sorrindo para você e que Atom em sites não tem nada a haver com bomba, então vejamos a estrutura da versão mais usada do RSS.

Estrutura do RSS

Elemento Descrição Exemplo
title Título da pagina que contém as notícias <title>feed</title>
link Link do site que possui a notícia <link>http://dns/</link>
description Frase que descreva o site da notícia <description>meu site é assim </description>
language Língua do site da notícia <language>pt-br</language>
copyright Observação de copyright <copyright>Copyright &copy; … </copyright>
managingEditor e-mail da pessoa responsável pela notícia <managingEditor>e-mail (nome)</managingEditor>
webMaster e-mail da pessoa responsável pela manutenção do RSS <webMaster>e-mail (nome) </webMaster>
pubDate Data da publicação do RSS <pubDate>Fri, 24 Jun 2005 02:40:25 GMT</pubDate>
lastBuildDate Data da última atualização <lastBuildDate>Fri, 24 Jun 2005 02:40:25 GMT</lastBuildDate>
category Categoria do RSS, onde domínio faz referência ao site que realiza a classificação RSS, e o conteúdo faz referência ao id gerado pelo site, a segunda tag informa a classificação a qual o RSS está registrado no classificador <category domain=”http://classificado/”>666</category>

<category>Tecnology</category>

generator Nome do software usado para criação do RSS <generator>KWrite</generator>
docs Url da documentação do formato usado no RSS <docs>http://dns/docsRSS.htm</docs>
could Permite que os clientes registrem o endereço do servidor RSS <cloud registerProcedure=”pingMe” port=”numroda porta” path=”/RPC2″ domain=”ip ou host ” protocol=”soap” />
ttl Número de minutos, indica qual o intervalo entre os refreshs do leitor RSS <ttl>20</ttl>
image Providencie conjunto de informações sobre a imagem do site <image>

<title>alt da imagem</title>

<url>url da imagem</url>

<link>http://dns/</link>

<width>88</width>

<height>31</height>

</image>

textInput Especifica parâmetros para buscas <textInput>

<title>Buscador</title>

<description>dado a ser buscado</description>

<name>nome do input do buscador</name>

<link>url contida no atributo action do formulário de busca</link>

</textInput>

skipHours Informa ao leitor rss quantas horas deve ficar sem fazer verificação <skipHours>

<hour>5</hour>

<hour>17</hour>

</skipHours>

skipDays Informa ao leitor rss quais dias não deve fazer verificação de nova notícia <skipDays>

<day>Sunday<day>

</skipDays>

item Providencie conjuntos de informações das notíciais <item>

<title>Titulo da matéria </title>

<link> link da matéria </link>

<guid isPermaLink=”true”> link da matéria </guid>

<description>Resumo da matéria</description>

<datePosted>Fri, 24 Jun 2005 02:40:25 GMT</datePosted>

<comments> Link dos cometários da matéria </comments>

<author>e-mail (nome) </author>

<source url=”link RSS da matéria”> Titulo do RSS
</source>

<enclosure url=”http://dns/rss.mp3″ length=”123326320″ type=”audo/mpeg” />

<category domain=”classificador”>666</category>

<category>Tecnology</category>

</item>

rating Número de acessos ao RSS, PICS, o conteúdo faz referência ao site que realiza suas estatísticas, ou de uma outra url que informe o número de acessos no padrão <rating>http://classificador/rating?id=666</rating>

Com a estrutura completa do RSS obtemos um XML parecido com o script a seguir.

<?xml version=“1.0″ encoding=“ISO-8859-1″?>
<rss version=“2.0″>
<channel>
<title>feed mxstudio</title>
<link>http://dns/rss.php</link>
<description>Meu site &eacute; assim</description>
<language>pt-br</language>
<copyright>Copyright&copy;MXSTUDIO</copyright>
<managingEditor>e-mail (nome)</managingEditor>
<webMaster>e-mail (nome) </webMaster>
<pubDate>Fri, 24 Jun 2005 02:40:25 GMT</pubDate>
<lastBuildDate>Fri, 24 Jun 2005 02:40:25 GMT</lastBuildDate>
<rating>http://classificador/rating?id=666</rating>
<category domain=“http://classificador/”>666</category>
<category>Tecnology</category>
<generator>KWrite</generator>
<docs>http://dns/</docs>
<cloud registerProcedure=“pingMe” port=“n&uacute;mroda porta” path=“/RPC2″ domain=“ip ou host “ protocol=“soap” />
<ttl>20</ttl>
<image>
<title>alt da imagem</title>
<url>url da imagem</url>
<link>http://dns/</link>
<width>88</width>
<height>31</height>
</image>
<textInput>
<title>Buscador </title>
<description>dado a ser buscado</description>
<name>nome do input do buscador</name>
<link>url contida no atributo action do formulário de busca</link>
</textInput>
<skipHours>
<hour>5</hour>
<hour>17</hour>
</skipHours>
<skipDays>
<day>Sunday</day>
</skipDays>
<item>
<title>Titulo da mat&eacute;ria [1]</title>
<link>link da mat&eacute;ria [1]</link>
<guid isPermaLink=“true”> link da mat&eacute;ria [1]</guid>
<description>Resumo da mat&eacute;ria [1]</description>
<datePosted>Fri, 24 Jun 2005 02:40:25 GMT</datePosted>
<comments> Link dos cometários da mat&eacute;ria [1]</comments>
<author>e-mail (nome) </author>
<source url=link RSS da mat&eacute;ria”> Titulo do RSS da mat&eacute;ria [1]</source>
<enclosure url=“http://dns/1.mp3″ length=“123326320″ type=“audo/mpeg” />
<category domain=“http://classificador/”>1</category>
<category>categoria da mat&eacute;ria [1]</category>
</item>
<item>
<title>Titulo da mat&eacute;ria [n]</title>
<link>link da mat&eacute;ria [n]</link>
<guid isPermaLink=“true”> link da mat&eacute;ria [n]</guid>
<description>Resumo da mat&eacute;ria [n]</description>
<datePosted>Fri, 24 Jun 2005 02:40:25 GMT</datePosted>
<comments> Link dos cometários da mat&eacute;ria [n]</comments>
<author>e-mail (nome) </author>
<source url=link RSS da mat&eacute;ria”> Titulo do RSS da mat&eacute;ria [1]</source>
<enclosure url=“http://dns/y.mp3″ length=“123326320″ type=“audo/mpeg” />
<category domain=“http://classificador/”>n</category>
<category>categoria da mat&eacute;ria [n]</category>
</item>
</channel>
</rss>

A Classe para leitura de RSS deve ser bem flexível, para que possa ler qualquer variante deste tipo de estrutura, e não retorne erros. A descrição da classe foi feita de forma simplificada. Então vejamos esta classe.

<!— Aqui inciamos um o componente ou classe —>
<cfcomponent displayname=”Leitor RSS”>
<!—
declaramos os atributos do componente, ou melhor, como estamos usando a tag cfproperty,
criamos as propriedades do componente, isto significa que futuramente poderemos transformar esta
classe em um tipo de dado, um exemplo de tipo de dado é o array, ou declarar dados complexos.
Quando iniciamos um objeto usando um componente com esta tag em seu escopo esses atributos estão
sujeitos as regras de herança.
—>
<cfproperty name=”url” type=”string” hint=”Endereço do RSS” />
<cfproperty name=”xmldoc” hint=”RSS no formato xml.” />
<cfproperty name=”title” type=”string” />
<cfproperty name=”link” type=”string” />
<cfproperty name=”description” type=”string” />
<cfproperty name=”pubDate” type=”string” />
<cfproperty name=”lastBuildDate” type=”string” />
<cfproperty name=”category” type=”struct” />
<cfproperty name=”image” type=”struct” />
<cfproperty name=”item” type=”query” />
<cfproperty name=”language” type=”string” />
<cfproperty name=”copyright” type=”string” />
<cfproperty name=”managingEditor” type=”string” />
<cfproperty name=”ttl” type=”string” />
<cfproperty name=”webMaster” type=”string” />
<cfproperty name=”generator” type=”string” />
<cfproperty name=”docs” type=”string” />
<cfproperty name=”could” type=”struct” />
<cfproperty name=”textInput” type=”struct” />
<cfproperty name=”skipHours” type=”array” />
<cfproperty name=”skipDays” type=”array” />
<cfproperty name=”rating” type=”string” />

<cffunction name=”setUrl” access=”public” output=”false” returntype=”string”
hint=”Método Atribui valor de url e inicializa objeto” >
<cfargument name=”url” type=”string” required=”yes” />
<!— inicia a aplicação —>
<cfset init(Arguments.url) />
</cffunction>

<cffunction name=”getUrl” access=”private” output=”false” returntype=”string”
hint=”Método retorna o valor de url” >
<cfreturn Iif(IsDefined(“instance.url”),DE(instance.url),DE(“”)) />
</cffunction>

<cffunction name=”setXMLdoc” access=”private” output=”false”
hint=”Método realiza requisição do RSS ao endereço armazenado em url e atribui valor a xmldoc”>
<!— torna privativa desta função a variável retornada pela tag cfhttp —>
<cfset var cfhttp=”" />
<!— torna privativa desta função a variável retornada pela tag cfcatch —>
<cfset var cfcatch=”" />
<cfif Len(Trim(instance.url))>
<!— aqui iniciamos um tratamento de erro, este assunto será tratado em uma outra matéria —>
<cftry>
<!—
Aqui realizamos um requisição de pagina a um outro servidor com auxílio da tag cfhttp.
Imagine que você abriu o browser digitou o endereço http://www.mxstudo.com.br/rss.php,
e salvou a pagina retornada em arquivo xml, bem é basicamente isto que esta tag faz,
ela faz uma requisição a uma url e salva o resultado em uma variável, e você tem algumas
opções de atributos, um em particular chamo a sua atenção, que é o atributo method.
Os valores para o atributo method podem ser get ou post, esta segunda opção faz com que
o cfhttp realize uma requisição de envio de formulário com o auxílio da tag cfhttpparam.
Esta tag é extremamente útil, produtiva e facilitadora, como já foi visto no fórum, faço uma resalva
sobre o uso indevido desta tag, que em alguns casos pode ser caracterizado como crime contra a propriedade intelectual,
ou até mesmo crime de apropriação indébita (roubo, roubo de informações).
—>
<cfhttp url=”#instance.url#” method=”get” redirect=”yes” timeout=”10″ />
<!— aqui é feito um parse do arquivo requisitado —>
<cfset instance.xmldoc = XMLParse(cfhttp.FileContent) />
<!— aqui é feito o tratamento o erro, este assunto será tratado em uma outra matéria —>
<cfcatch type=”any”>
<cfset instance.xmldoc = “” />
</cfcatch>
</cftry>
</cfif>
</cffunction>

<cffunction name=”getXMLdoc” access=”private” output=”false” returntype=”any”
hint=”Método retorna retorna o valor de xmldoc” >
<cfscript>
if(IsDefined(“instance.xmldoc”))
return instance.xmldoc;
return “”;
</cfscript>
</cffunction>

<cffunction name=”setTitle” access=”private” output=”false”
hint=”Método atribui valor a title”>
<cfset instance.title = XMLSearchXmlText(“/rss/channel/title”) />
</cffunction>

<cffunction name=”getTitle” access=”private” output=”false” returntype=”string”
hint=”Método retorna valor de title”>
<cfreturn Iif(IsDefined(“instance.title”),DE(instance.title),DE(“”)) />
</cffunction>

<cffunction name=”setLink” access=”private” output=”false”
hint=”Método atribui valor a link”>
<cfset instance.link = XMLSearchXmlText(“/rss/channel/link”) />
</cffunction>

<cffunction name=”getLink” access=”private” output=”false” returntype=”string”
hint=”Método retorna o valor de link” >
<cfreturn Iif(IsDefined(“instance.link”),DE(instance.link),DE(“”)) />
</cffunction>

<cffunction name=”setDescription” access=”private” output=”false”
hint=”Método atribui valor a description”>
<cfset instance.description = XMLSearchXmlText(“/rss/channel/description”) />
</cffunction>

<cffunction name=”getDescription” access=”private” output=”false” returntype=”string”
hint=”Método retorna valor de description”>
<cfreturn Iif(IsDefined(“instance.description”),DE(instance.description),DE(“”)) />
</cffunction>

<cffunction name=”setPubDate” access=”private” output=”false”
hint=”Método atribui valor a pubDate”>
<cfset instance.pubDate = XMLSearchXmlText(“/rss/channel/pubDate”) />
</cffunction>

<cffunction name=”getPubDate” access=”private” output=”false” returntype=”string”
hint=”Método retorna valor de pubDate” >
<cfreturn Iif(IsDefined(“instance.pubDate”),DE(instance.pubDate),DE(“”)) />
</cffunction>

<cffunction name=”setLastBuildDate” access=”private” output=”false”
hint=”Método atribui valor a lastBuildDate”>
<cfset instance.lastBuildDate = XMLSearchXmlText(“/rss/channel/lastBuildDate”) />
</cffunction>

<cffunction name=”getLastBuildDate” access=”private” output=”false” returntype=”string”
hint=”Método retorna valor de lastBuildDate” >
<cfreturn Iif(IsDefined(“instance.lastBuildDate”),DE(instance.lastBuildDate),DE(“”)) />
</cffunction>

<cffunction name=”searchCategory” returntype=”struct” access=”private” output=”false”>
hint=”Consulta atributos da tag category e retorna os valores nela contido”>
<cfargument name=”path” required=”yes” type=”array” />
<cfscript>
//inicia as posições no array
var posa = 1;
var posb = 1;
var retorno = StructNew();
//verifica o tamanho do array
switch(ArrayLen(Arguments.path)){
case “2″:{ //array com duas posições
//testa os atributos procurando por um key, e define a posição e relação a esse teste
posa = Iif(StructKeyExists(Arguments.path[1].XmlAttributes,”domain”),1,2);
//testa a posição recibida anteriormente e atualiza a posição seguinte
posb = Iif(posa EQ 1,2,1);
//realiza as atribuições
retorno = Arguments.path[posa].XmlAttributes;
retorno["id"] = Arguments.path[posa].XmlText;
retorno["category"] = Arguments.path[posb].XmlText;
break;
}
case “1″:{
retorno["category"] = Arguments.path[1].XmlText;
break;
}
}
return retorno;
</cfscript>
</cffunction>

<cffunction name=”setCategory” access=”private” output=”false”
hint=”Método atribui valor a category”>
<cfset instance.category = searchCategory(XMLSearch(instance.xmldoc,”/rss/channel/category”)) />
</cffunction>

<cffunction name=”getCategory” access=”private” output=”false” returntype=”struct”
hint=”Método retorna valor de category”>
<cfscript>
if(IsDefined(“instance.category”))
return instance.category;
return StructNew();
</cfscript>
</cffunction>

<cffunction name=”setImage” access=”private” output=”false”
hint=”Método atribui valor a image”>
<cfscript>
//busca tag imagem
var temp = XMLSearch(instance.xmldoc,”/rss/channel/image”);
//cria array com os nomes das possíveis tags filhas de imagem
var itens = ListToArray(“title,url,link,width,height”);
//inicia index do for
var i = 1;
/*testa para saber se a tag imagem foi encontrada, caso exista terá ao menos uma posição*/
if(ArrayLen(temp))
//loop com o número de tags filhas
for(;i LTE ArrayLen(itens);i = i +1)
//teste para saber se as tags filhas existem em imagem
if(StructKeyExists(temp[1],itens[i]))
instance.image[itens[i]] = temp[1][itens[i]].XmlText;
</cfscript>
</cffunction>

<cffunction name=”getImage” access=”private” output=”false” returntype=”struct”
hint=”Método retorna valor de image” >
<cfscript>
if(IsDefined(“instance.image”))
return instance.image;
return StructNew();
</cfscript>
</cffunction>

<cffunction name=”setItens” access=”private” output=”false”
hint=”Método realiza converção do rss no formato xml para
formato query e atribui valor a item”>
<cfscript>
var xmlArr = “”;
var tag = “”;
var i = 1;
var j = 1;
var temp = “”;

//Existem quatro tipos de tags em item, que são:
// 1 – tags possuindo XmlAttributes e XmlText que se repetem (category)
// 2 – tags possuindo apenas XmlText
var columnsA = ListToArray(“title,link,description,datePosted,comments,author”);
// 3 – tags possuindo apenas XmlAttributes
var columnsB = ListToArray(“url,length,type”);
// 4 – tags possuindo XmlAttributes e XmlText
var columnsC = StructNew();
columnsC["guid"] = “isPermaLink”;
columnsC["source"] = “url”;
//consulto xml procurando pelas tag item retornando um array
xmlArr = XMLSearch(instance.xmldoc,”/rss/channel/item”);
if(ArrayLen(xmlArr)){
temp = “title,link,guid,description,datePosted,comments,author,source”;
temp = temp&”,guid_isPermaLink,source_url,enclosure_url,enclosure_length”;
temp = temp&”,enclosure_type,category_domain,category_id,category”;
//inicio uma consulta informando os nomes das colunas em uma lista delimitar por vírgula

instance.item = QueryNew(temp);
//informa a consulta quantos registros ela vai possuir
QueryAddRow(instance.item, ArrayLen(xmlArr));
for(; i LTE ArrayLen(xmlArr); i=i+1){
//tags possuindo apenas XmlText
for(j=1;j LTE ArrayLen(columnsA);j=j+1){
if(StructKeyExists(xmlArr[i],columnsA[j]))
QuerySetCell(instance.item,columnsA[j],xmlArr[i][columnsA[j]].XmlText,i);
}
//tags possuindo apenas XmlAttributes
if(StructKeyExists(xmlArr[i],”enclosure”)){
for(j=1;j LTE ArrayLen(columnsB);j=j+1){
if(StructKeyExists(xmlArr[i].enclosure.XmlAttributes,columnsB[j]))
QuerySetCell(instance.item,”enclosure_”&columnsB[j],xmlArr[i].enclosure.XmlAttributes[columnsB[j]],i);
}
}
//tags possuindo XmlAttributes e XmlText
for(tag in columnsC){
if(StructKeyExists(xmlArr[i],tag)){
QuerySetCell(instance.item,tag,xmlArr[i][tag].XmlText,i);
if(StructKeyExists(xmlArr[i][tag].XmlAttributes,columnsC[tag]))
QuerySetCell(instance.item,tag&”_”&columnsC[tag],xmlArr[i][tag].XmlAttributes[columnsC[tag]],i);
}
}
//tags possuindo XmlAttributes e XmlText que se repetem (category)
tag = searchCategory(XmlSearch(xmlArr[i],”category”));
QuerySetCell(instance.item,”category”,tag["category"],i);
if(StructKeyExists(tag,”id”)){
QuerySetCell(instance.item,”category_id”,tag["id"],i);
QuerySetCell(instance.item,”category_domain”,tag["domain"],i);
}

}
}
</cfscript>
</cffunction>

<cffunction name=”getItens” access=”private” output=”false” returntype=”query”
hint=”Método retorna o valor de item” >
<cfscript>
temp = “title,link,guid,description,datePosted,comments,author,source”;
temp = temp&”,guid_isPermaLink,source_url,enclosure_url,enclosure_length”;
temp = temp&”,enclosure_type,category_domain,category_id,category”;

if(IsDefined(“instance.item”))
return instance.item;
return QueryNew(temp);
</cfscript>
</cffunction>

<cffunction name=”setLanguage” access=”private” output=”false”
hint=”Método atribui valor a language”>
<cfset instance.language = XMLSearchXmlText(“/rss/channel/language”) />
</cffunction>

<cffunction name=”getLanguage” access=”private” output=”false” returntype=”string”
hint=”Método retorna valor de language”>
<cfreturn Iif(IsDefined(“instance.language”),DE(instance.language),DE(“”)) />
</cffunction>

<cffunction name=”setCopyright” access=”private” output=”false”
hint=”Método atribui valor a copyright”>
<cfset instance.copyright = XMLSearchXmlText(“/rss/channel/copyright”) />
</cffunction>

<cffunction name=”getCopyright” access=”private” output=”false” returntype=”string”
hint=”Método retorna valor de copyright”>
<cfreturn Iif(IsDefined(“instance.copyright”),DE(instance.copyright),DE(“”)) />
</cffunction>

<cffunction name=”setManagingEditor” access=”private” output=”false”
hint=”Método atribui valor a managingEditor”>
<cfset instance.managingEditor = XMLSearchXmlText(“/rss/channel/managingEditor”) />
</cffunction>

<cffunction name=”getManagingEditor” access=”private” output=”false” returntype=”string”
hint=”Método retorna valor de managingEditor”>
<cfreturn Iif(IsDefined(“instance.managingEditor”),DE(instance.managingEditor),DE(“”)) />
</cffunction>

<cffunction name=”setTtl” access=”private” output=”false”
hint=”Método atribui valor a ttl”>
<cfset instance.ttl = XMLSearchXmlText(“/rss/channel/ttl”) />
</cffunction>

<cffunction name=”getTtl” access=”private” output=”false” returntype=”string”
hint=”Método retorna valor de ttl”>
<cfreturn Iif(IsDefined(“instance.ttl”),DE(instance.ttl),DE(“”)) />
</cffunction>

<cffunction name=”setWebMaster” access=”private” output=”false”
hint=”Método atribui valor a webMaster”>
<cfset instance.webMaster = XMLSearchXmlText(“/rss/channel/webMaster”) />
</cffunction>

<cffunction name=”getWebMaster” access=”private” output=”false” returntype=”string”
hint=”Método retorna valor de webMaster”>
<cfreturn Iif(IsDefined(“instance.webMaster”),DE(instance.webMaster),DE(“”)) />
</cffunction>

<cffunction name=”setGenerator” access=”private” output=”false”
hint=”Método atribui valor a generator”>
<cfset instance.generator = XMLSearchXmlText(“/rss/channel/generator”) />
</cffunction>

<cffunction name=”getGenerator” access=”private” output=”false” returntype=”string”
hint=”Método retorna valor de generator”>
<cfreturn Iif(IsDefined(“instance.generator”),DE(instance.generator),DE(“”)) />
</cffunction>

<cffunction name=”setDocs” access=”private” output=”false”
hint=”Método atribui valor a docs”>
<cfset instance.docs = XMLSearchXmlText(“/rss/channel/docs”) />
</cffunction>

<cffunction name=”getDocs” access=”private” output=”false” returntype=”string”
hint=”Método retorna valor de docs”>
<cfreturn Iif(IsDefined(“instance.docs”),DE(instance.docs),DE(“”)) />
</cffunction>

<cffunction name=”setCould” access=”private” output=”false”
hint=”Método atribui valor a could”>
<cfscript>
var temp = XMLSearch(instance.xmldoc,”/rss/channel/cloud”);
if(ArrayLen(temp) AND IsStruct(temp[1].XmlAttributes))
instance.could = temp[1].XmlAttributes;
</cfscript>
</cffunction>

<cffunction name=”getCould” access=”private” output=”false” returntype=”struct”
hint=”Método retorna valor de could”>
<cfscript>
if(IsDefined(“instance.could”))
return instance.could;
return StructNew();
</cfscript>
</cffunction>

<cffunction name=”setTextInput” access=”private” output=”false”
hint=”Método atribui valor a textInput”>
<cfscript>
if(ArrayLen(XMLSearch(instance.xmldoc,”/rss/channel/textInput”))){
instance.textInput["title"] = XMLSearchXmlText(“/rss/channel/textInput/title”);
instance.textInput["description"] = XMLSearchXmlText(“/rss/channel/textInput/description”);
instance.textInput["name"] = XMLSearchXmlText(“/rss/channel/textInput/name”);
instance.textInput["link"] = XMLSearchXmlText(“/rss/channel/textInput/link”);
}
</cfscript>
</cffunction>

<cffunction name=”getTextInput” access=”private” output=”false” returntype=”struct”
hint=”Método retorna valor de textInput”>
<cfscript>
if(IsDefined(“instance.textInput”))
return instance.textInput;
return StructNew();
</cfscript>
</cffunction>

<cffunction name=”setSkipHours” access=”private” output=”false”
hint=”Método atribui valor a skipHours”>
<cfscript>
var temp = XMLSearch(instance.xmldoc,”/rss/channel/skipHours/hour”);
var i = 1;
if(ArrayLen(temp)){
for(; i LTE ArrayLen(temp);i=i+1)
temp[i] = temp[i].XmlText;
instance.skipHours = temp;
}
</cfscript>
</cffunction>

<cffunction name=”getSkipHours” access=”private” output=”false” returntype=”array”
hint=”Método retorna valor de skipHours”>
<cfscript>
if(IsDefined(“instance.skipHours”))
return instance.skipHours;
return ArrayNew(1);
</cfscript>
</cffunction>

<cffunction name=”setSkipDays” access=”private” output=”false”
hint=”Método atribui valor a skipDays”>
<cfscript>
var temp = XMLSearch(instance.xmldoc,”/rss/channel/skipDays/day”);
var i = 1;
if(ArrayLen(temp)){
for(; i LTE ArrayLen(temp);i=i+1)
temp[i] = temp[i].XmlText;
instance.skipDays = temp;
}
</cfscript>
</cffunction>

<cffunction name=”getSkipDays” access=”private” output=”false” returntype=”array”
hint=”Método retorna valor de skipDays”>
<cfscript>
if(IsDefined(“instance.skipDays”))
return instance.skipDays;
return ArrayNew(1);
</cfscript>
</cffunction>

<cffunction name=”setRating” access=”private” output=”false”
hint=”Método atribui valor a rating”>
<cfset instance.rating = XMLSearchXmlText(“/rss/channel/rating”) />
</cffunction>

<cffunction name=”getRating” access=”private” output=”false” returntype=”string”
hint=”Método retorna valor de rating”>
<cfreturn Iif(IsDefined(“instance.rating”),DE(instance.rating),DE(“”)) />
</cffunction>

<cffunction access=”public” name=”init” output=”false”
hint=”Método inicia o componente chamando todo método de atribuição de valores,
setUrl foi suprimido pela existência deste método”>
<cfargument name=”url” type=”string” required=”yes”
hint=”Informe um endereço de RSS (válido)” />
<cfscript>
instance.url = Arguments.url;
setXMLdoc();
setTitle();
setDescription();
setCategory();
setLink();
setImage();
setLastBuildDate();
setPubDate();
setItens();
setLanguage();
setCopyright();
setManagingEditor();
setTtl();
setWebMaster();
setGenerator();
setDocs();
setCould();
setTextInput();
setSkipHours();
setSkipDays();
setRating();
</cfscript>
</cffunction>

<cffunction name=”getRss” access=”public” output=”false” returntype=”struct”
hint=”Método retorna todos os atributos em uma estrutura”>
<cfscript>
var retorno=StructNew();
retorno.xmldoc=getXMLdoc();
retorno.item=getItens();
retorno.title=getTitle();
retorno.link=getLink();
retorno.url=getUrl();
retorno.image=getImage();
retorno.pubDate=getPubDate();
retorno.lastBuildDate=getLastBuildDate();
retorno.description=getDescription();
retorno.category=getCategory();
retorno.language=getLanguage();
retorno.copyright=getCopyright();
retorno.managingEditor=getManagingEditor();
retorno.ttl=getTtl();
retorno.webMaster=getWebMaster();
retorno.generator=getGenerator();
retorno.docs=getDocs();
retorno.could=getCould();
retorno.textInput=getTextInput();
retorno.skipHours=getSkipHours();
retorno.skipDays=getSkipDays();
retorno.rating=getRating();
return retorno;
</cfscript>
</cffunction>

<cffunction name=”get” access=”public” output=”false” returntype=”any”
hint=”Método retorna atributos solicitados em uma estrutura, simples (apenas uma soliciatção) ou complexa (mais de uma solicitação) “>
<cfscript>
var retorno = StructNew();
var i = 1;
/*lista com todos os possiveis metodos que podem ser executados sem parametro*/
var metodos = “XMLdoc,Item,Title,Link,Url,Image,PubDate,LastBuildDate,”;

metodos = metodos&”,Description,Category,Language,Copyright,ManagingEditor,Ttl”;
metodos = metodos&”,WebMaster,Generator,Docs,Could,TextInput,SkipHours,SkipDays,Rating”;

//verifca a presença de parametros
if(IsDefined(“Arguments”)){
//loop com o número de parametros
for(; i LTE ArrayLen(Arguments);i=i+1){
/*acerta o nome do metodo que possui a primeira letra após o get em maiuscula e o restante sendo minuscula */
Arguments[i] = Ucase(Left(Arguments[i],1))&Lcase(Right(Arguments[i],Len(Arguments[i])-1));
//valida o nome do método, procurando na lista de métodos
if(ListFind(metodos,Arguments[i])){
if(ArrayLen(Arguments) EQ 1)
return Evaluate(“get#Arguments[i]#()”); //retorno simples
//rearruma a lista para que não duplique resultados
metodos = ListDeleteAt(metodos,ListFind(metodos,Arguments[i]));
//acrescenta o retorno da execução atual na estrutura de retorno
StructInsert(retorno,Lcase(Arguments[i]),Evaluate(“get#Arguments[i]#()”),true);
}
}
}
return retorno;
</cfscript>
</cffunction>

<cffunction name=”XMLSearchXmlText” access=”private” returntype=”string”>
<cfargument name=”node” type=”string” required=”yes” />
<cfscript>
temp = XMLSearch(instance.xmldoc,Arguments.node);
if(ArrayLen(temp))
return temp[1].XmlText;
return “”;
</cfscript>
</cffunction>

<cffunction name=”searchItem” access=”public” returntype=”query”>
<cfargument name=”campos” type=”string” required=”yes” />
<cfargument name=”item” type=”string” required=”yes” />
<cfargument name=”valor” type=”string” required=”yes” />
<cfset var qItem = QueryNew(”) />
<cftry>
<cfquery name=”qItem” dbtype=”query”>
select #Trim(Arguments.campos)#
from instance.item
where #Trim(Arguments.item)# = ‘#Trim(Arguments.valor)#’
</cfquery>
<cfcatch type=”database”></cfcatch>
</cftry>
<cfreturn qItem />
</cffunction>

</cfcomponent>

Agora será feita uma sequência de dumps do objeto RSS para saber o que ele nos retorna, e com isso veremos também como funciona a interface do dump que é bastante elaborada.

Instanciando um objeto RSS

<cfset rss=CreateObject(“component”,”rss.rss”) />
<cfset rss.init(“http://localhost:8300/rss/mxstudio.xml”) />
<cfdump var=”#rss#”>
<cfset rss = “nothing” />

Estrutura do objeto RSS apenas instanciado

component rss.rss
GETRSS
function getRss
Arguments: none
Return Type: struct
Roles:
Access: public
Output: false
GET
function get
Arguments: none
Return Type: any
Roles:
Access: public
Output: false
SETURL
function setUrl
Arguments:

Name Required Type Default
url Required string
Return Type: string
Roles:
Access: public
Output: false
INIT
function init
Arguments:

Name Required Type Default
url Required string
Return Type:
Roles:
Access: public
Output: false
SEARCHITEM
function searchItem
Arguments:

Name Required Type Default
campos Required string
item Required string
valor Required string
Return Type: query
Roles:
Access: public
Output: Yes

Instanciando um objeto RSS e reutilizando o objeto para ser usado como variável de acesso direto.

<cfset rss=CreateObject(“component”,”rss.rss”) />
<cfset rss.init(“http://localhost:8300/rss/mxstudio.xml”) />
<cfset rss['dados'] = rss.getRss() />
<cfdump var=”#rss#”>
<cfset rss = “nothing” />

Nova estrutura do objeto RSS

component rss.rss
DADOS
struct
CATEGORY
struct
category Tecnology
domain http://classificador/
id 666
COPYRIGHT Copyright©MXSTUDIO
COULD
struct
domain ip ou host
path /RPC2
port númroda porta
protocol soap
registerProcedure pingMe
DESCRIPTION Meu site é assim
DOCS http://dns/
GENERATOR KWrite
IMAGE
struct
height 31
link http://dns/
title alt da imagem
url url da imagem
width 88
ITEM
query – Rows: 2
AUTHOR CATEGORY CATEGORY_DOMAIN CATEGORY_ID COMMENTS DATEPOSTED DESCRIPTION ENCLOSURE_LENGTH ENCLOSURE_TYPE ENCLOSURE_URL GUID GUID_ISPERMALINK LINK SOURCE SOURCE_URL TITLE
1 e-mail (nome) categoria da matéria [1] http://classificador/ 666 Link dos comet?rios da matéria [1] Fri, 24 Jun 2005 02:40:25 GMT Resumo da matéria [1] 123326320 audo/mpeg http://dns/rss.mp3 link da matéria [1] true link da matéria [1] Titulo do RSS da matéria [1] link RSS da matéria Titulo da matéria [1]
2 e-mail (nome) categoria da matéria [n] http://classificador/ 666 Link dos comet?rios da matéria [n] Fri, 24 Jun 2005 02:40:25 GMT Resumo da matéria [n] 123326320 audo/mpeg http://dns/rss.mp3 link da matéria [n] true link da matéria [n] Titulo do RSS da matéria [n] link RSS da matéria Titulo da matéria [n]
LANGUAGE pt-br
LASTBUILDDATE Fri, 24 Jun 2005 02:40:25 GMT
LINK http://dns/rss.php
MANAGINGEDITOR e-mail (nome)
PUBDATE Fri, 24 Jun 2005 02:40:25 GMT
RATING http://classificador/rating?id=666
SKIPDAYS
array
1 Sunday
SKIPHOURS
array
1 5
2 17
TEXTINPUT
struct
description dado a ser buscado
link url contida no atributo action do foruml?rio de busca
name nome do input do buscador
title Buscador
TITLE feed mxstudio
TTL 20
URL http://localhost:8300/rss/mxstudio.xml
WEBMASTER e-mail (nome)
XMLDOC
xml document [short version]
XmlComment
XmlRoot
xml element
XmlName rss
XmlNsPrefix
XmlNsURI
XmlText
XmlComment
XmlAttributes
struct
version 2.0
XmlChildren
xml element
XmlName channel
XmlNsPrefix
XmlNsURI
XmlText
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName title
XmlNsPrefix
XmlNsURI
XmlText feed mxstudio
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName link
XmlNsPrefix
XmlNsURI
XmlText http://dns/rss.php
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName description
XmlNsPrefix
XmlNsURI
XmlText Meu site é assim
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName language
XmlNsPrefix
XmlNsURI
XmlText pt-br
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName copyright
XmlNsPrefix
XmlNsURI
XmlText Copyright©MXSTUDIO
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName managingEditor
XmlNsPrefix
XmlNsURI
XmlText e-mail (nome)
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName webMaster
XmlNsPrefix
XmlNsURI
XmlText e-mail (nome)
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName pubDate
XmlNsPrefix
XmlNsURI
XmlText Fri, 24 Jun 2005 02:40:25 GMT
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName lastBuildDate
XmlNsPrefix
XmlNsURI
XmlText Fri, 24 Jun 2005 02:40:25 GMT
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName rating
XmlNsPrefix
XmlNsURI
XmlText http://classificador/rating?id=666
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName category
XmlNsPrefix
XmlNsURI
XmlText 666
XmlComment
XmlAttributes
struct
category Tecnology
domain http://classificador/
id 666
XmlChildren
xml element
XmlName category
XmlNsPrefix
XmlNsURI
XmlText Tecnology
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName generator
XmlNsPrefix
XmlNsURI
XmlText KWrite
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName docs
XmlNsPrefix
XmlNsURI
XmlText http://dns/
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName cloud
XmlNsPrefix
XmlNsURI
XmlText
XmlComment
XmlAttributes
struct
domain ip ou host
path /RPC2
port númroda porta
protocol soap
registerProcedure pingMe
XmlChildren
xml element
XmlName ttl
XmlNsPrefix
XmlNsURI
XmlText 20
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName image
XmlNsPrefix
XmlNsURI
XmlText
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName title
XmlNsPrefix
XmlNsURI
XmlText alt da imagem
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName url
XmlNsPrefix
XmlNsURI
XmlText url da imagem
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName link
XmlNsPrefix
XmlNsURI
XmlText http://dns/
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName width
XmlNsPrefix
XmlNsURI
XmlText 88
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName height
XmlNsPrefix
XmlNsURI
XmlText 31
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName textInput
XmlNsPrefix
XmlNsURI
XmlText
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName title
XmlNsPrefix
XmlNsURI
XmlText Buscador
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName description
XmlNsPrefix
XmlNsURI
XmlText dado a ser buscado
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName name
XmlNsPrefix
XmlNsURI
XmlText nome do input do buscador
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName link
XmlNsPrefix
XmlNsURI
XmlText url contida no atributo action do foruml?rio de busca
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName skipHours
XmlNsPrefix
XmlNsURI
XmlText
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName hour
XmlNsPrefix
XmlNsURI
XmlText 5
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName hour
XmlNsPrefix
XmlNsURI
XmlText 17
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName skipDays
XmlNsPrefix
XmlNsURI
XmlText
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName day
XmlNsPrefix
XmlNsURI
XmlText Sunday
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName item
XmlNsPrefix
XmlNsURI
XmlText
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName title
XmlNsPrefix
XmlNsURI
XmlText Titulo da matéria [1]
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName link
XmlNsPrefix
XmlNsURI
XmlText link da matéria [1]
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName guid
XmlNsPrefix
XmlNsURI
XmlText link da matéria [1]
XmlComment
XmlAttributes
struct
isPermaLink true
XmlChildren
xml element
XmlName description
XmlNsPrefix
XmlNsURI
XmlText Resumo da matéria [1]
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName datePosted
XmlNsPrefix
XmlNsURI
XmlText Fri, 24 Jun 2005 02:40:25 GMT
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName comments
XmlNsPrefix
XmlNsURI
XmlText Link dos comet?rios da matéria [1]
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName author
XmlNsPrefix
XmlNsURI
XmlText e-mail (nome)
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName source
XmlNsPrefix
XmlNsURI
XmlText Titulo do RSS da matéria [1]
XmlComment
XmlAttributes
struct
url link RSS da matéria
XmlChildren
xml element
XmlName enclosure
XmlNsPrefix
XmlNsURI
XmlText
XmlComment
XmlAttributes
struct
length 123326320
type audo/mpeg
url http://dns/rss.mp3
XmlChildren
xml element
XmlName category
XmlNsPrefix
XmlNsURI
XmlText 666
XmlComment
XmlAttributes
struct
category categoria da matéria [1]
domain http://classificador/
id 666
XmlChildren
xml element
XmlName category
XmlNsPrefix
XmlNsURI
XmlText categoria da matéria [1]
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName item
XmlNsPrefix
XmlNsURI
XmlText
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName title
XmlNsPrefix
XmlNsURI
XmlText Titulo da matéria [n]
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName link
XmlNsPrefix
XmlNsURI
XmlText link da matéria [n]
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName guid
XmlNsPrefix
XmlNsURI
XmlText link da matéria [n]
XmlComment
XmlAttributes
struct
isPermaLink true
XmlChildren
xml element
XmlName description
XmlNsPrefix
XmlNsURI
XmlText Resumo da matéria [n]
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName datePosted
XmlNsPrefix
XmlNsURI
XmlText Fri, 24 Jun 2005 02:40:25 GMT
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName comments
XmlNsPrefix
XmlNsURI
XmlText Link dos comet?rios da matéria [n]
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName author
XmlNsPrefix
XmlNsURI
XmlText e-mail (nome)
XmlComment
XmlAttributes
struct [empty]
XmlChildren
xml element
XmlName source
XmlNsPrefix
XmlNsURI
XmlText Titulo do RSS da matéria [n]
XmlComment
XmlAttributes
struct
url link RSS da matéria
XmlChildren
xml element
XmlName enclosure
XmlNsPrefix
XmlNsURI
XmlText
XmlComment
XmlAttributes
struct
length 123326320
type audo/mpeg
url http://dns/rss.mp3
XmlChildren
xml element
XmlName category
XmlNsPrefix
XmlNsURI
XmlText 666
XmlComment
XmlAttributes
struct
category categoria da matéria [n]
domain http://classificador/
id 666
XmlChildren
xml element
XmlName category
XmlNsPrefix
XmlNsURI
XmlText categoria da matéria [n]
XmlComment
XmlAttributes
struct [empty]
XmlChildren
rss
XmlText
XmlAttributes
struct
version 2.0
channel
XmlText
title
XmlText feed mxstudio
link
XmlText http://dns/rss.php
description
XmlText Meu site é assim
language
XmlText pt-br
copyright
XmlText Copyright©MXSTUDIO
managingEditor
XmlText e-mail (nome)
webMaster
XmlText e-mail (nome)
pubDate
XmlText Fri, 24 Jun 2005 02:40:25 GMT
lastBuildDate
XmlText Fri, 24 Jun 2005 02:40:25 GMT
rating
XmlText http://classificador/rating?id=666
category
XmlText 666
XmlAttributes
struct
category Tecnology
domain http://classificador/
id 666
category
XmlText Tecnology
generator
XmlText KWrite
docs
XmlText http://dns/
cloud
XmlText
XmlAttributes
struct
domain ip ou host
path /RPC2
port númroda porta
protocol soap
registerProcedure pingMe
ttl
XmlText 20
image
XmlText
title
XmlText alt da imagem
url
XmlText url da imagem
link
XmlText http://dns/
width
XmlText 88
height
XmlText 31
textInput
XmlText
title
XmlText Buscador
description
XmlText dado a ser buscado
name
XmlText nome do input do buscador
link
XmlText url contida no atributo action do foruml?rio de busca
skipHours
XmlText
hour
XmlText 5
hour
XmlText 17
skipDays
XmlText
day
XmlText Sunday
item
XmlText
title
XmlText Titulo da matéria [1]
link
XmlText link da matéria [1]
guid
XmlText link da matéria [1]
XmlAttributes
struct
isPermaLink true
description
XmlText Resumo da matéria [1]
datePosted
XmlText Fri, 24 Jun 2005 02:40:25 GMT
comments
XmlText Link dos comet?rios da matéria [1]
author
XmlText e-mail (nome)
source
XmlText Titulo do RSS da matéria [1]
XmlAttributes
struct
url link RSS da matéria
enclosure
XmlText
XmlAttributes
struct
length 123326320
type audo/mpeg
url http://dns/rss.mp3
category
XmlText 666
XmlAttributes
struct
category categoria da matéria [1]
domain http://classificador/
id 666
category
XmlText categoria da matéria [1]
item
XmlText
title
XmlText Titulo da matéria [n]
link
XmlText link da matéria [n]
guid
XmlText link da matéria [n]
XmlAttributes
struct
isPermaLink true
description
XmlText Resumo da matéria [n]
datePosted
XmlText Fri, 24 Jun 2005 02:40:25 GMT
comments
XmlText Link dos comet?rios da matéria [n]
author
XmlText e-mail (nome)
source
XmlText Titulo do RSS da matéria [n]
XmlAttributes
struct
url link RSS da matéria
enclosure
XmlText
XmlAttributes
struct
length 123326320
type audo/mpeg
url http://dns/rss.mp3
category
XmlText 666
XmlAttributes
struct
category categoria da matéria [n]
domain http://classificador/
id 666
category
XmlText categoria da matéria [n]
SETURL
function setUrl
Arguments:

Name Required Type Default
url Required string
Return Type: string
Roles:
Access: public
Output: false
SEARCHITEM
function searchItem
Arguments:

Name Required Type Default
campos Required string
item Required string
valor Required string
Return Type: query
Roles:
Access: public
Output: Yes
GETRSS
function getRss
Arguments: none
Return Type: struct
Roles:
Access: public
Output: false
GET
function get
Arguments: none
Return Type: any
Roles:
Access: public
Output: false
INIT
function init
Arguments:

Name Required Type Default
url Required string
Return Type:
Roles:
Access: public
Output: false

Executando uma consulta nas notícias do RSS

<cfset rss=CreateObject(“component”,”rss.rss”) />
<cfset rss.init(“http://localhost:8300/rss/mxstudio.xml”) />
<cfdump var=”#rss.searchItem(‘title’,'author’,'e-mail (nome)’)#” />
<cfset rss = “nothing” />

Retorno da consulta

query – Rows: 2
TITLE
1 Titulo da matéria [1]
2 Titulo da matéria [n]

Instanciando um objeto RSS e exibindo uma informação do cabeçalho do RSS

<cfset rss=CreateObject(“component”,”rss.rss”) />
<cfset rss.init(“http://localhost:8300/rss/mxstudio.xml”) />
<cfoutput>#rss.get(“title”)#</cfoutput>
<cfset rss = “nothing” />

O retorno desta solicitação é uma variável de estrutura simples

feed mxstudio

Instanciando um objeto RSS e exibindo multiplas informações do cabeçalho do RSS

<cfset rss=CreateObject(“component”,”rss.rss”) />
<cfset rss.init(“http://localhost:8300/rss/mxstudio.xml”) />
<cfdump var=”#rss.get(‘title’,'url’)#” />
<cfset rss = “nothing” />

O retorno desta solicitação é uma variável de estrutura complexa (tipo estrutura)

struct
title feed mxstudio
url http://localhost:8300/rss/mxstudio.xml

Escrito por Pedro Claudio on junho 29, 2005. Arquivado em Coldfusion. Você pode seguir as respostas a esse artigo pelo RSS 2.0. Você pode deixar respostas para esse artigo

Deixe uma resposta

O seu endereço de email não será publicado Campos obrigatórios são marcados *

*

Você pode usar estas tags e atributos de HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>