Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
XML Parser to/from foxpro
Message
De
28/02/2002 13:19:00
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00626116
Message ID:
00626577
Vues:
14
>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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform