You can embed a HMG RSS? / Se puede incrustar un RSS en HMG?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
danielmaximiliano
Posts: 2359
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 434 times
Been thanked: 84 times
Contact:

Re: You can embed a HMG RSS? / Se puede incrustar un RSS en

Post by danielmaximiliano »

Andres : puedes enviarme la modificacion (rss.prg) a mi mail para probar

danielmaximiliano@yahoo.com.ar
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO

User avatar
andyglezl
Posts: 1251
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 39 times
Been thanked: 107 times
Contact:

Post by andyglezl »

Hola Daniel

Solo modifiqué en el siguiente Procedure

Code: Select all

PROCEDURE DownloadRss( nCat )
    LOCAL oHttp  , oDoc        , oItem , oCurrent , oIterator
    LOCAL cTitle , cDescription, cXML

    ReaderRSSnews.ReadsNews.DeleteAllItems
    SWITCH nCat
        CASE 1
            *oHttp:= TIpClientHttp():new( "http://feeds.folha.uol.com.br/emcimadahora/rss091.xml" )
            oHttp:= TIpClientHttp():new( "http://www.bbc.co.uk/mundo/america_latina/index.xml" )         // <--------
            EXIT
        CASE 2
            *oHttp:= TIpClientHttp():new( "http://feeds.folha.uol.com.br/esporte/rss091.xml" )
            oHttp:= TIpClientHttp():new( "http://www.bbc.co.uk/mundo/ciencia_tecnologia/index.xml" )    // <--------
            EXIT
        CASE 3
            oHttp:= TIpClientHttp():new( "http://feeds.folha.uol.com.br/poder/rss091.xml" )
            EXIT
        CASE 4
            oHttp:= TIpClientHttp():new( "http://feeds.folha.uol.com.br/mercado/rss091.xml" )
            EXIT
        CASE 5
            oHttp:= TIpClientHttp():new( "http://feeds.folha.uol.com.br/ciencia/rss091.xml" )
            EXIT
    ENDSWITCH

    oHttp:open()
    cXML := oHttp:readAll()
    *cXML := hb_AnsiToOem( oHttp:readAll() )     // <--------  Quise cambiarle aqui por los acentos
    *cXML := hb_OemToAnsi( oHttp:readAll() )     // <--------
    oHttp:close()

    // Descomente aqui para grabar  XML en disco
    // uncomment these lines if not want to record the current document
     MemoWrit( "test.xml" , cXML )

    oDoc := TXmlDocument():New( cXML )
    IF oDoc:nError != HBXML_ERROR_NONE
       MsgExclamation( "Error : " + Str( oDoc:nError ) , "Error message" )
       RETURN
    ENDIF
    *oItem := oDoc:findfirst( "item" )
    oItem := oDoc:findfirst( "entry" )     // <--------   Cambié "item" por "entry"
    IF oItem == NIL
       MsgInfo( "No News found" ,"Atenttion message" )
       RETURN
    ENDIF
    DO WHILE .T.
      cTitle         := ""
      cDescription    := ""
      oIterator     := TXmlIterator():New( oItem )
      DO WHILE .T.
         oCurrent := oIterator:Next()
         IF oCurrent == NIL
             AAdd( aTitle       , cTitle )
             AAdd( aDescription , cDescription )
            EXIT
         ELSE
            IF oCurrent:cName == "title"
               *cTitle := hb_ansitooem( oCurrent:cData )
               cTitle := oCurrent:cData     // <--------  Quite hb_AnsiToOem()
               ReaderRSSnews.ReadsNews.AddItem( cTitle )
            *ELSEIF oCurrent:cName == "description"
            ELSEIF oCurrent:cName == "summary"     // <--------   Cambié "description" por "summary"
                *cDescription := RemoverTags( hb_AnsiToOem( oCurrent:cData ) )
                cDescription := RemoverTags( oCurrent:cData )     // <--------  Quite hb_AnsiToOem()
                ReaderRSSnews.Content.Value := cDescription
            ENDIF
         ENDIF
      ENDDO
      oItem := oDoc:findnext()
      IF oItem == NIL
         EXIT
      ENDIF
    ENDDO     /* While .T. */
RETURN

NOTA: Parece que no se le puede poner color en el código cuando se ponen etiquetas "code -- /code"
te señale las lineas con flechas.
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
danielmaximiliano
Posts: 2359
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 434 times
Been thanked: 84 times
Contact:

Post by danielmaximiliano »

Hola a Todos :
Hi Everyone:

Andrés , corregi la acentúacion faltaba trabajar con Unicode con
Andrés , corrected Missing accentuation work with Unicode.

Code: Select all

 SET TO UNICODE CODEPAGE 
ya que el XML es UTF8
as the XML is UTF8
Código fuente original.jpg
Código fuente original.jpg (96.95 KiB) Viewed 3067 times
RSS reader news.jpg
RSS reader news.jpg (40.85 KiB) Viewed 3067 times
ahora el XML generado se guarda en la carpeta \Xml\test.xml
Now the generated XML is stored in the \Xml\test.xml
Attachments
Rss.rar
(192.14 KiB) Downloaded 150 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO

User avatar
andyglezl
Posts: 1251
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 39 times
Been thanked: 107 times
Contact:

Post by andyglezl »

Hola Daniel

Probe con el "SET TO UNICODE CODEPAGE" que mencionas en el post y me da error.
En el .prg tienes "SET CODEPAGE TO UNICODE" y tambien me da error.

El unico comando que encontré es el: "SET CODEPAGE TO ..."

Estoy utilizando HMG 3.46, será para versiones más actuales ?
-----------------------------------------------------------------------------------

Hi Daniel

Try the "SET TO UNICODE CODEPAGE" you mention in your post and it gives me error.
In the. Prg you have "SET TO UNICODE CODEPAGE" and I also fails.

The only thing I found is the command: "SET CODEPAGE TO ..."

I am using 3.46 HMG will be for current versions?
Attachments
Setcodepage.png
Setcodepage.png (215.75 KiB) Viewed 3060 times
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
danielmaximiliano
Posts: 2359
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 434 times
Been thanked: 84 times
Contact:

Post by danielmaximiliano »

Si.. es para HMG.3.1.3 por eso el error
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO

User avatar
andyglezl
Posts: 1251
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 39 times
Been thanked: 107 times
Contact:

Post by andyglezl »

Hola a todos

"googleando", me encontre un scrip para solucionar el problema de los acentos y Ññ,
( en mi caso, HMG 3.46 ) y le "saqué la vuelta" de la siguiente forma.
Modifiqué las siguientes lineas(en rojo):

--------------------------------------------------------------------------
Hello everyone

"googling", I found a script to solve the problem of accents and Ññ,
(In my case, HMG 3.46) and "pulled back" in the following way.
I modified the following lines ( in red ):

.............
oHttp:open()
cXML := oHttp:readAll()
oHttp:close()

// Descomente aqui para grabar XML en disco
// uncomment these lines if not want to record the current document
MemoWrit( "testUTF8.xml" , cXML )
ShellExecute(0, "open", "UTF82ANSI.vbs", "testUTF8.xml test.xml", , 0)
cXML:=MemoRead( "test.xml" )


oDoc := TXmlDocument():New( cXML )
IF oDoc:nError != HBXML_ERROR_NONE
MsgExclamation( "Error : " + Str( oDoc:nError ) , "Error message" )
RETURN
ENDIF
...........


*-------------------------------------------------
* SCRIPT UTF82ANSI.vbs
*-------------------------------------------------
Option Explicit

Private Const adReadAll = -1
Private Const adSaveCreateOverWrite = 2
Private Const adTypeBinary = 1
Private Const adTypeText = 2
Private Const adWriteChar = 0

Private Sub UTF8toANSI(ByVal UTF8FName, ByVal ANSIFName)
Dim strText

With CreateObject("ADODB.Stream")
.Open
.Type = adTypeBinary
.LoadFromFile UTF8FName
.Type = adTypeText
.Charset = "utf-8"
strText = .ReadText(adReadAll)
.Position = 0
.SetEOS
.Charset = "iso-8859-1"
.WriteText strText, adWriteChar
.SaveToFile ANSIFName, adSaveCreateOverWrite
.Close
End With
End Sub

UTF8toANSI WScript.Arguments(0), WScript.Arguments(1)
---------------------------------------------------------

No se si este Script se pueda hacer dentro de HMG, espero les sirva.

Script do not know if this can be done within HMG, I hope they serve.
Attachments
RSS4.png
RSS4.png (47.41 KiB) Viewed 3042 times
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
andyglezl
Posts: 1251
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 39 times
Been thanked: 107 times
Contact:

Post by andyglezl »

Hola de nuevo
Creo que el punto está en poder hacer lo siguiente en HMG.
---------------------------------------------------------
Hello again
I think the point is to do the following in HMG.
---------------------------------------------------------
.
.
.
.Charset = "utf-8"
strText = .ReadText(adReadAll)
.
.
.
.Charset = "iso-8859-1"
.WriteText strText, adWriteChar
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
danielmaximiliano
Posts: 2359
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 434 times
Been thanked: 84 times
Contact:

Post by danielmaximiliano »

Andrés :
Utilizaste

Code: Select all

HB_Translate( <cString>        , ;
              <cCodePageID_Src>, ;
              <cCodePageID_Tgt>  ) --> cConvertedString
seria algo asi :

Code: Select all

 
cXML_utf8 := oHttp:readAll()
cXML_ansi := HB_Translate( cXML_utf8    , "UTF8" , "ESWIN"  )

// dejamos el XML en UTF8
MemoWrit( "Xml\test.xml" , cXML_utf8 )

 // pero usamos ANSI para trabajar con el documento
    oDoc := TXmlDocument():New(cXML_ansi )
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO

User avatar
andyglezl
Posts: 1251
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 39 times
Been thanked: 107 times
Contact:

Post by andyglezl »

Gracias Daniel, con lo anterior funciona OK
(desconocia esa función)
-------------------------------------
Thanks Daniel, with the above works OK
(did not know this function)
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
andyglezl
Posts: 1251
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 39 times
Been thanked: 107 times
Contact:

Post by andyglezl »

Hola Daniel

Aqui de nuevo, en las pruebas iniciales no valide la información
y resulta que en el programa (HMG) no actualiza los datos leidos,
siempre me aparecen los que consulté por primera vez.
Ya corrí el CCleaner para borrar temporales y cookies
y me sigue apareciendo la misma información. ??????

Alguna idea ?

NOTA: No chequé si la información de tus páginas
que pusiste de ejemplo sea la misma.
Y parece que no hay un estandar (a menos que sea por País)
el manejo de los .RSS ya que varios links no los puede leer.

-----------------------------------------------------
Hi Daniel

Here again, in the initial tests did not validate the information
and it turns out in the program (HMG) does not update the data read,
I always appear first I consulted.
I ran CCleaner to clear temporary cookies
and I still see the same information. ??????

Any idea?

NOTE: No I checked if the information of your pages
you put an example is the same .
And it seems that there is no standard (unless by Country)
the RSS file management because multiple links can not be read.
Attachments
RSS5.png
RSS5.png (403.49 KiB) Viewed 2970 times
Andrés González López
Desde Guadalajara, Jalisco. México.

Post Reply