Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Browsing through nodes in XMLDOM
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Web Services
Divers
Thread ID:
00661456
Message ID:
00661480
Vues:
34
This message has been marked as the solution to the initial question of the thread.
>I have an xml file that talks to one of my web services. This xml file always holds one record. Also, the format is not as simple as the one generated by cursortoxml, but a little more complex. I was advised here to use xmldom to browse through the xml file, but i find it difficult to find what i need in order to execute a simple task:
>i would like to loop through all the nodes. If the name of the node is some field i need, i'll just save it in a variable. That's it! Could anyone give me an example on how to achieve this?

Assuming the xml file you're talking about is the one you posted in Message#658658:
loXML = CREATEOBJECT("MSXML2.DOMDocument.3.0")
loXML.Async = .F.
* read xml doc
loXML.loadXML(FILETOSTR("msg658658.xml"))

loRoot = loXML.documentElement
IF !ISNULL(loRoot)

  * read and display country code
  loElm = loRoot.selectSingleNode("country")
  ? "Country code:",loElm.text

  * read and display pick_up_location
  loElm = loRoot.selectSingleNode("pick_up/pick_up_location")
  ? "Pick up location:",loElm.text

ENDIF
----------------------------------
António Tavares Lopes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform