Número 53 • noviembre 2008

Visual Basic•C#•ASP.NET•ADO.NET•AJAXSilverlight.NET Framework

dotNetManía

Revista dedicada a los profesionales de la plataforma .NET

Menú

Inicio

Números publicados

Libros

Próximo número (nº54)

Autores

¿Qué es dotNetManía?

Garantía de satisfacción

Contactar

Envíenos su feedback

Pedidos

Suscripciones

Renovaciones

Libros

Publicidad


SP1 de Visual Studio 2008

Patrocinadores

Patrocinador Oro
Microsoft

Patrocinador Plata
Alhambra-Eidos

Patrocinadores Bronce
ABOX
Domitienda
Krasis
Plain Concepts
Raona
Solid Quality Mentors

 

 

 

Nº 1 Febrero 2004 Intercambiando contenidos en RSS con ASP.NET Material de apoyo

Por Jorge Serrano

Cuando comenzó Internet, nadie conocía el alcance real que hoy día tiene. Lo más valioso de la red de redes es la información, pero ¿tenemos control sobre la información que se publica en Internet y tenemos acceso a ella fácilmente?.


RSS no es otra cosa que un documento XML que sigue una serie de reglas que permiten traducir los contenidos de estos documentos para que sean interpretables por cualquier aplicación que lo trate.

Quien es Dave Winer

Dave Winer es el fundador de Userland Software y socio del Berkman Center donde se gestó el actual RSS 2.0. ¿El padrino de la especificación RSS 2.0?


Más información
http://blogs.law.harvard-edu/tech/rss/
http://www.ee/support/Official/intro.html
http://www.w3.org/Protocols/rfc822/

Especificación RDF
http://www.w3.org/RDF/
http://www.w3.org/TR/1999/REC-rdf-syntax-19990222/

Códigos de países (RFC 3166 que sustituye a la RFC 1766)
http://ftp.ics.uci.edu/pub/ietf/http/related/iso3166.txt

Cabeceras de contenidos de paíss (RFC 3282 que sustituye a la RFC 1766)
http://www.faqs.org/rfcs/rfc3282.html

FAQ de Dave Winer sobre las políticas de RSS 2.0
http://backend.userland.com/davesRss2PoliticalFaq

Artículo de Gary Lawrence Murphy: ¿Dave Winer prohíbe el uso de RSS?
http://www.ecademy.com/node.php?id=8871


Código fuente

<?xml version="1.0"?>

<rss version="2.0">

  <channel>

    <title>Título_del_Sitio_Web</title>

    <link>Dirección_de_la_Página_Web</link>

    <description>Descripción_del_Sitio_Web</description>

    <language>Nombre_de_Cultura_o_Idioma_con_RFC_1766</language>

    <item>

      <title>Título_del_Artículo</title>

      <description>Descripción_del_Artículo</description>

      <link>Dirección_Web_del_artículo</link>

      <pubDate>Fecha_Hora_GMT_con_RFC_822</pubDate>

    </item>

    <item>

      <title>Título_del_Artículo</title>

      <description>Descripción_del_Artículo</description>

      <link>Dirección_Web_del_artículo</link>

      <pubDate>Fecha_Hora_GMT</pubDate>

    </item>

  </channel>

</rss>

 

Fuente 1. Ejemplo de documento RSS 2.0

 

<?xml version="1.0"?>

<rss version="2.0">

  <channel>

    <title>Mi Intranet</title>

    <link>http://localhost/</link>

    <description>Esta es mi Web de pruebas</description>

    <language>es-ES</language>

    <item>

      <title>DotNetMania</title>

      <description>Pagina Web de la revista</description>

      <link>http://www.dotnetmania.com/</link>

      <pubDate>Mon, 01 Jan 2004 01:12:23 GMT</pubDate>

    </item>

    <item>

      <title>Microsoft MSDN .NET</title>

      <description>Pagina web de Microsoft .NET</description>

      <link>http://msdn.microsoft.com/netframework/</link>

      <pubDate>Mon, 01 Jan 2004 07:28:15</pubDate>

    </item>

  </channel>

</rss>

Fuente 2. MiRSS.xml

 

<%@ Page Language="VB" %>

<script runat="server">

Private Enum HTML

    title

    link

    description

    language

    pubDate

    NewLine

End Enum

 

 

Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    Dim strInfoSite As String = ""

    Dim strInfoArticulo As String = ""

    Dim XmlReader As New System.Xml.XmlTextReader("http://localhost/MiRSS.xml")

 

    XmlReader.WhitespaceHandling = System.Xml.WhitespaceHandling.None

    XmlReader.MoveToContent()

 

        While XmlReader.Read

            If XmlReader.LocalName = "channel" And XmlReader.NodeType = System.Xml.XmlNodeType.Element Then

                Do Until XmlReader.LocalName = "item"

                    XmlReader.Read()

                    If XmlReader.LocalName = "title" And XmlReader.NodeType = System.Xml.XmlNodeType.Element Then

                        XmlReader.Read()

                        Preparar_Cadena(strInfoSite, XmlReader.Value, HTML.title)

                    End If

                    If XmlReader.LocalName = "link" And XmlReader.NodeType = System.Xml.XmlNodeType.Element Then

                        XmlReader.Read()

                        Preparar_Cadena(strInfoSite, XmlReader.Value, HTML.link)

                    End If

                    If XmlReader.LocalName = "description" And XmlReader.NodeType = System.Xml.XmlNodeType.Element Then

                        XmlReader.Read()

                        Preparar_Cadena(strInfoSite, XmlReader.Value, HTML.description)

                    End If

                    If XmlReader.LocalName = "language" And XmlReader.NodeType = System.Xml.XmlNodeType.Element Then

                        XmlReader.Read()

                        Preparar_Cadena(strInfoSite, XmlReader.Value, HTML.language)

                    End If

                    If XmlReader.NodeType = System.Xml.XmlNodeType.None Then

                        Preparar_Cadena(strInfoSite, XmlReader.Value, HTML.NewLine)

                    End If

                Loop

            End If

            If XmlReader.LocalName = "item" And XmlReader.NodeType = System.Xml.XmlNodeType.Element Then

                Do While XmlReader.Read

                    If XmlReader.LocalName = "title" And XmlReader.NodeType = System.Xml.XmlNodeType.Element Then

                        XmlReader.Read()

                        Preparar_Cadena(strInfoArticulo, XmlReader.Value, HTML.title)

                    End If

                    If XmlReader.LocalName = "link" And XmlReader.NodeType = System.Xml.XmlNodeType.Element Then

                        XmlReader.Read()

                        Preparar_Cadena(strInfoArticulo, XmlReader.Value, HTML.link)

                    End If

                    If XmlReader.LocalName = "description" And XmlReader.NodeType = System.Xml.XmlNodeType.Element Then

                        XmlReader.Read()

                        Preparar_Cadena(strInfoArticulo, XmlReader.Value, HTML.description)

                    End If

                    If XmlReader.LocalName = "pubDate" And XmlReader.NodeType = System.Xml.XmlNodeType.Element Then

                        XmlReader.Read()

                        Preparar_Cadena(strInfoArticulo, XmlReader.Value, HTML.pubDate)

                    End If

                    If XmlReader.NodeType = System.Xml.XmlNodeType.None Then

                        Preparar_Cadena(strInfoArticulo, XmlReader.Value, HTML.NewLine)

                    End If

                Loop

            End If

        End While

    Label1.Text = strInfoSite & strInfoArticulo

    XmlReader.Close()

End Sub

 

Private Sub Preparar_Cadena(ByRef strCadena As String, ByVal strVariable As String, ByVal AccionHTML As HTML)

    Select Case AccionHTML

        Case HTML.title

            strCadena = strCadena & "<h1>" & strVariable & "</h1>"

        Case HTML.link

            strCadena = strCadena & "<a href='" & strVariable & "'>" & strVariable & "</a>"

        Case HTML.description

            strCadena = strCadena & "<h4>" & strVariable & "</h4>"

        Case HTML.language

            strCadena = strCadena & "<h5>" & strVariable & "</h5>"

        Case HTML.pubDate

            strCadena = strCadena & "<h5>" & strVariable & "</h5>"

        Case HTML.NewLine

            strCadena = strCadena & "<br>"

    End Select

End Sub

 

</script>

 

 

<html>

 

<head>

<title>Lectura de Documentos RSS 2.0</title>

</head>

 

 

<body>

 

<form runat="server" ID="Form1">

 

<asp:Button id="Button1" runat="server" Text="Visualizar el documento RSS" OnClick="Button1_Click" />

 

<br>

 

<asp:Label id="Label1" runat="server" />

 

</form>

 

 

</body>

 

</html>

 

RSS.ASPX

 

Volver
 


dotNetManía es una revista editada por Netalia. Más información.