ATOUTFOX
COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO
Visual FoxPro : le développement durable

Lecture d'un RSS (version XmlAdapter)   



L'auteur

Thierry
France France
Membre Simple
# 0000000016
enregistré le 13/10/2004

52 ans
PERRETIER Thierry
92800 PUTEAUX
Fiche personnelle


Note des membres
pas de note

Contributions > 20 - Trucs et Astuces

Lecture d'un RSS (version XmlAdapter)
# 0000000178
ajouté le 25/04/2005 10:47:54 et modifié le 25/04/2005
consulté 8953 fois
Niveau initié

Version(s) Foxpro :
VFP 9.0
VFP 8.0

Description

Le schéma XML est importé à partir de la structure des curseurs Foxpro.

NB :

- le format de date des RSS n'est pas reconnu par XmlAdapter.

- La procédure Modif_XMLname permet d'assurer la correspondance exacte (majuscule/minuscule) des identifiants XML avec les noms de champs du curseur Foxpro.

Code source :
LOCAL oXml as Microsoft.XMLHTTP
oXml = CreateObject("Microsoft.XMLHTTP")
oXml.open("GET","http://www.atoutfox.org/rss_contribs.asp")
oXml.send()
local cXml
WAIT WINDOW "..." nowait
DO WHILE oXml.readyState<>4
    doevents
ENDDO
WAIT clear
cXml=oXml.responseBody
LOCAL o as XMLAdapter
o=NewObject("XmlAdapter")
o.LoadXML(cXml)

CREATE CURSOR channel (title c(100), link c(68), description m, author c(30), pubdate c(31))
o.AddTableSchema("channel")
Modif_XMLname(o.tables(1),"pubdate","pubDate")
o.tables.item(1).toCursor(.t.,"channel")
BROWSE nowait

CREATE CURSOR item (title c(100), link c(68), description m, author c(30), pubdate c(31))
o.AddTableSchema("item")
mModif_XMLname(o.tables(2),"pubdate","pubDate")
o.tables.item(2).toCursor(.t.,"item")
BROWSE nowait

PROCEDURE Modif_XMLname(oXmlTable as XMLtable, cAncien, cNouveau)
    LOCAL oField as XMLField
    LOCAL i
    i=oXmlTable.Fields.GetKey(Strconv(cAncien,12))
    oField  = oXmlTable.Fields(i)
    oXmlTable.Fields.remove(i)
    oField.XMLName=Strconv(cNouveau,12)
    oXmlTable.Fields.Add(oField , oField.XMLName)
ENDPROC
Commentaires
Aucun commentaire enregistré ...

Publicité

Les pubs en cours :

www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2024.
Cette page est générée par un composant COM+ développé en Visual FoxPro 9.0-SP2-HF3