Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XML Parser to/from foxpro
Message
From
28/02/2002 13:19:00
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00626116
Message ID:
00626577
Views:
24
>Is there a way in Foxpro to read and/or create XML files .

Here's an example of using simple strings to create XML, and then using Microsoft's standard parse to both read and make modifications to the document:
LOCAL lcXML
TEXT TO lcXML NOSHOW
<messages>
	<message to="you">
		<body>Body Goes Here</body>
	</message>
	<message to="me">
		<body>Body of Message number 2</body>
	</message>
</messages>
ENDTEXT 

* Create the parser object
loXML = CREATEOBJECT('msxml2.domdocument')
loXML.async = .F.

* Load teh XML
loXML.loadXML(lcXML)

* Loop through all the messages, request the Body element, and read its text
loMessages = loXML.documentElement.selectNodes('message')
FOR EACH loMessage IN loMessages

	loBody = loMessage.selectSingleNode('body')
	?loBody.text


	* Replace the Body with info about the recipient
	loBody.text = 'Here is the new message for ' + loMessage.getAttribute("to")
	lcXML = loXML.xml

ENDFOR 

* Display the new XML
?lcXML
If you any questions on this in general, or a specific part, I'd be happy to clarify the code.
Previous
Reply
Map
View

Click here to load this message in the networking platform