Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using XMLTOCURSOR()
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01554474
Message ID:
01554483
Vues:
70
As Sergey mentioned using a schema is ideal. If the data comes from a .NET dataset export the dataset with a schema which is the easiest.

If you don't have a schema you can pre-create the cursor to import to and XMLTOCURSOR() can infer the schema based on the cursor's structure. The following works:
TEXT TO lcXmL NOSHOW
<DataBase>
 <ConnectionInfo>
  <DBKey>1</DBKey>
  <String>SQLNCLI10</String> 
  </ConnectionInfo>
</DataBase>
ENDTEXT

CREATE CURSOR TData (DbKey n(5), String c(20))

XMLTOCURSOR(lcXml,"TData",8192)

BROWSE
+++ Rick ---

>Anyone can explain why I am getting a different result using the following expression:
>
>
>cFileName = "test.xml"
>XMLTOCURSOR(cFileName,"alias_name", 512)
>
>
>The content of text.xml looks like following:
>
><DataBase>
> <ConnectionInfo>
>  <DBKey>1</DBKey>
>  <String>SQLNCLI10</String> 
>  </ConnectionInfo>
> <ConnectionInfo>
>  <DBKey>2</DBKey>
>  <String>SQLNCLI10</String> 
>  </ConnectionInfo>
></DataBase>
>
>
>The above XML file produces a cursor with the column DBKey is number, 1 and 2. This is what I expect.
>
>But if I have only one element ConnectionInfo as following:
>
><DataBase>
> <ConnectionInfo>
>  <DBKey>1</DBKey>
>  <String>SQLNCLI10</String> 
>  </ConnectionInfo>
></DataBase>
>
>
>Then the above test.xml produces a cursor where the column DBKey is .T.
>
>Why? Could someone explain what I am missing?
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform