Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get a value from XML file without converting it to DBF
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01687978
Message ID:
01687983
Views:
29
Thank you.

>Hmm,
>
>
>_Screen.ADDOBJECT("filecache", "Collection")
>***
>lcFile="Any.xml"
>lcHASH=SYS(2007, lcFile, 0, 1)
>
>liIndex=_Screen.filecache.GetKey(lcHASH)
>IF liIndex=0
>   lcXML=FILETOSTR(lcFile)
>   _Screen.filecache.ADD(lcXML, lcHASH)
>ELSE
>   lcXML=_Screen.filecache.Item(liIndex)
>ENDIF
>
>
>
>MartinaJ
>
>>Just a follow up question. The reason I was concerned about using FILETOSTR() function is that I would need to use it about 100 times, randomly. That is, the same value (e.g. "any.xml") could be used more than one time and therefore, my code would have to Get this file (e.g. "any.xml") into a string more than 1 time. Then, maybe after 2-3 iterations, do it again, do it again.
>>
>>Do you see any problem with getting a string about 100 times (using FILETOSTR())?
>>
>>>Hi,
>>>
>>> You need STREXTRACT() function:
>>>
>>>
>>>m.lcXML=FILETOSTR("any.xml")
>>>?STREXTRACT(m.lcXML, "<cmwo_name1>", "</cmwo_name1>")
>>>?STREXTRACT(m.lcXML, "<cmwo_name2>", "</cmwo_name2>")
>>>?STREXTRACT(m.lcXML, "<cmwo_name3>", "</cmwo_name3>")
>>>
>>>
>>>MartinaJ
>>>
>>>>Hi,
>>>>
>>>>I am experimenting with getting a value from an XML file without converting this XML file to an DBF.
>>>>Here is an example. Say I have the following XML file:
>>>>
>>>><?xml version = "1.0" encoding="Windows-1252" standalone="yes"?>
>>>><VFPData>
>>>>	<cm_system_preferences>
>>>>		<cmwo_name1>N</cmwo_name1>
>>>>		<cmwo_name2>Y</cmwo_name1>
>>>>		<cmwo_name3>100</cmwo_name3>
>>>>	</cm_system_preferences>
>>>></VFPData>
>>>>
>>>>Say I want to get the value in the element by the name (e.g. by "cmwo_name1, or cmwo_name2, and so on).
>>>>For example, I want to extract from the XML file that the setting of the "name cmwo_name2" is Y (True). Or that the value of the name "cmwo_name3" is 100.
>>>>
>>>>How do I do it in code?
>>>>
>>>>TIA
"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
Previous
Reply
Map
View

Click here to load this message in the networking platform