Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need some XML parsing help
Message
From
27/03/2005 19:43:46
 
 
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
00999113
Message ID:
00999351
Views:
18
This message has been marked as the solution to the initial question of the thread.
Glenn,

I have had some struggles with this recently as well. Rick's suggestion of XPATH is correct, but it can really be painful at first. Try this as a sample:
loXml = NEWOBJECT("MSXML2.DomDocument")
loXml.async = .F.  
IF loXml.load("x.xml")
    * pulling the price from the 'c' section in your example
    lcPrice = loXml.documentElement.selectSingleNode("//datafield[@tag='260']/subfield[@code='c']").text
ENDIF
There are extra things you need to check for to make it robust, i.e. that selectSingleNode returned an object, that the object has elements. Where most people get stuck is not realising they can nest the query information.

HTH
- Craig

"If you're not prepared to be wrong, you will never come up with anything original."
- Sir Ken Robinson
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform