Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Xmltocursor
Message
De
15/03/2003 17:43:37
 
 
À
07/03/2003 12:08:28
Information générale
Forum:
Visual FoxPro
Catégorie:
XML, XSD
Titre:
Divers
Thread ID:
00762807
Message ID:
00766242
Vues:
22
Hi Mark,

It is very easy to do in VFP8 using new XMLAdapter class:

*********************
CLOSE DATABASES all
clear
TEXT TO cXML NOSHOW
<?xml version="1.0"?>
<root  xmlns:dt="urn:schemas-microsoft-com:datatypes" >
<application>
	<id dt:dt="number">3</id>
	<acronym>ABC</acronym>
	<version dt:dt="number">6.3</version>
	<name>American Broadcasting Corporation</name>
	<status>Development</status>
	<PAC-status>N/A</PAC-status>
	<department>Sales</department>
</application>
</root>
ENDTEXT

LOCAL oXA as XMLAdapter, oXT as XMLTable, oXF as XMLField
oXA=CREATEOBJECT("XMLAdapter")

* create cursor
CREATE CURSOR application (;
id I, ;
acronym c(3), ;
version n(3,1), ;
name c(40), ;
status c(15),;
PAC_status c(3),;
department c(10))

oXA.AddTableSchema(ALIAS(),.T.)
oXA.XMLSchemaLocation="" && do not process schema during load
oXA.LoadXML(cXML,.F.,.F.)
oXT =oXA.Tables(1)

* modify schema to match XML

* change table element name to low case (AddTableSchema uses upper case)
oXA.Tables.Remove(1)
oXT.XMLName=STRCONV("application",5)
oXA.Tables.Add(oXT,oXT.XMLName)

* take care of PAC-status element name
oXF=oXT.Fields(6)
oXT.Fields.Remove(6)
oXF.XMLName=STRCONV("PAC-status",5)
oXT.Fields.Add(oXF,oXF.XMLName,6)

* get data
oXT.ToCursor(.T.)
list
*********************

Thanks,
Aleksey Tsingauz.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform