Bienvenido: ( Identificarse | Registrarse )      
Foros de Trucos Windows
 
Closed TopicStart new topicStart Poll

Outline · [ Estándar ] · Lineal+

> sindicar mis noticias

emr
post Jul 18 2005, 05:38 PM
Publicado: #1


Newbie
*

Grupo: Members
Mensajes: 1
Registrado: 18-July 05
Miembro nº: 145.015



hola a tod@s!!
estoy creando una aplicación web para un periódico digital. Me gustaría hacer que se pudiesen sindicar las noticias, con xml. Pero, la verdad que no tengo muy claro como hacerlo.
En principio he hecho lo siguiente:

/*escribir el ppio del archibo xml*/
public XmlTextWriter escribirInicioRSS(System.Xml.XmlTextWriter writer)
{
writer.WriteStartDocument();
writer.WriteStartElement("rss");
writer.WriteAttributeString("version","2.0");
writer.WriteStartElement("channel");
writer.WriteElementString("title","titulo");
writer.WriteElementString("link","link");
writer.WriteElementString("description","descripcion");
writer.WriteElementString("languaje","es-es");
writer.WriteElementString("generator","Creador de RSS por Elena");
return writer;
}


/*para añadir cada uno de los elementos al archivo*/
public XmlTextWriter agregarItemRSS(XmlTextWriter writer,string sTitulo,string stexto,string sFechapub,string sAutor,int idarticulo)
{
writer.WriteStartElement("item");
writer.WriteElementString("title",sTitulo);
writer.WriteElementString("description",stexto);
writer.WriteElementString("pubDate",sFechapub);
writer.WriteElementString("author",sAutor);
string cadena="http://localhost/interfaz/Artículo.aspx?idarticulo="
+idarticulo.ToString();
writer.WriteElementString("link",cadena);
writer.WriteEndElement();

return writer;
}


/*para cerrar el documento xml*/
public System.Xml.XmlTextWriter escribirFinalRSS()
{
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
return writer;
}

Bien, en el documento de origen (donde está el botoncito naranja de XML) se recogen los datos de cada uno de los artículos y se llama a la funcion añadirItemRSS.
El objeto writer está así definido:

XmlTextWriter writer= new XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8);

Y, una vez que se han agregado todos los item y se ha llamado a la función escribirFinalRSS, añado lo siguiente:

writer.Flush();
writer.Close();
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "text/xml";
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.End();

Sin embargo, cuando intento añadir la dirección de mi feed a un lector...me pide una contraseña y username, x lo que deduzco que hago algo mal
alguien m puede ayudar???
(ejem...ya sé...el código no está ni en c ni en c++....es c#...pero si m pueden ayudar lo agradecería)
gracias. un saludo


User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
Closed TopicTopic OptionsStart new topic

Collapse

> Topicos similares

Noticias curiosas y raras xMIMIx 782 30 Jan 28 2008, 07:26 PM
By: xMIMIx
Infección por noticias musicales marga2f 107 0 Dec 21 2007, 05:17 AM
By: marga2f
DesignFloat - Noticias relacionadas al mundo del marga2f 217 0 Sep 18 2007, 02:44 PM
By: marga2f
gestor de noticias alfonsolist 363 2 Aug 25 2007, 11:40 AM
By: alfonsolist
Desesperado con poner imagen en noticias PHPNUKE firwart 598 4 Jan 11 2007, 03:59 AM
By: Lord MinDokan

Google
Web www.trucoswindows.net