Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determine if XML has tag?
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01573926
Message ID:
01574036
Vues:
43
>Hi,
>
>I am retrieving content of an XML into a cursor using the XMLTOCURSOR() function as follows:
>
>create cursor c_test ( field1 c(20), field2 c(20), field3 n(5,0), field4 c(30), field5 c(1))
>xmltocursor( 'MyXmlfile.xml', 'c_test', 512 + 8192 )
>
>
>The XML has tags for fields field1, field2, field3. But may or may not have tags for field4 and field5. I know that xmltocursor() will work even if XML does not have these tags as the columns in the cursor will be empty. But it is possible that the tags in the XML are empty too. So checking if the columns field4 and/or field5 have entry does not tell me abut the XML. What I am trying to determine if the XML does or does not have the tags for columns field4 and field5. Is it possible just from the code above or I would have to open the XML field (using FILETOSTR() or some other way) before creating the cursor and importing the content of the xml into the cursor?
>
>TIA.

I figured how I can do it. When creating new XML format that will have elements field4 and field5 (new elements) I will also add a flag element (e.g. new_xml int). And since user will not have access to this element, I will set the value myself (e.g. 1). So after retrieving the XML file into the cursor I will check the value of the field new_xml of the first record. And if it is 1, I know that the XML is of new format.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform