Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Newbie question on processing XML file
Message
 
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Miscellaneous
Thread ID:
00854652
Message ID:
00854676
Views:
25
Hi Sergey,
Yes, I knew that I could do it by parsing the xml file.

But I want to learn the XML DOM functions and thought that someone might suggest a way to do it using XMLAdapter or some other DOM-specific functions.

Thank you.

>Hi Dmitry,
>
>You can do that with pure VFP code.
lcStr = STREXTRACT(lcXml, "<service>", "</service>")
>lnTotItems = OCCURS("<add", lcStr)
>FOR lnItem = 1 TO lnTotItems
>	lcKey = EVALUATE(ALLTRIM(STREXTRACT(lcStr, "<add key=", "value=", lnItem)))
>	lcVal = EVALUATE(ALLTRIM(STREXTRACT(lcStr, "value=", "/>", lnItem)))
>	? lnItem, lcKey, lcVal
>ENDFOR
>>How would I process the following XML file?:
>>
>>
>><?xml version="1.0"?>
>><service>
>>   <add key="key1" value="value1" />
>>   <add key="key2" value="value2" />
>></service>
>>
>>
>>I want to extract values corresponding to different keys in the file.
>>
>>TIA for any suggestions.
"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
Next
Reply
Map
View

Click here to load this message in the networking platform