Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Processing an XML file to VFP cursors
Message
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Miscellaneous
Thread ID:
00904549
Message ID:
00904813
Views:
30
Carmel
If you use VFP8, just check out the XMLAdapter Class.
If you are using previous versions, you should manually scan your xml using XMLDom and enter the data into your tables.
Scannig your data manually would look something like the following:
ox = CreateObject("MSXml.DOMDocument")
ox.Load( YourXmlSource ) && or ox.LoadXML( YourXMLString )
myXmlString = ox.DocumentElement
** now retrieve some fields **
myRevNode = myXmlString.SelectSingleNode( "authentication/revision" )
myRevision = myRevNode.Text
myResNode = myXmlString.SelectSingleNode( "authentication/reseller_shortcut")
MyReseller = myResNode.Text

** loop through the customer nodes
myCustomers = myXmlString.SelectNodes( "customers" )
for each oCostumer in myCustomers
   tmpName = oCostumer.SelectSingleNode("customer/name")
   ? tmpName.Text
endfor
** it's a pain, i know, but you can control everything
HTH
Jaime

>Hi all,
>
>Here is an extract from an XML file that I am getting from a third party vendor with 1 record that I am trying to get into cursors in VFP. I want to strip out the authentication> area as well as the and put customers, billing, sales, shipping and contact into cursors ?
>
>Please help! I am new to the whole XML thing and unsure as to how to go about this.
>
>
>
><?xml version="1.0" encoding="UTF-8"?>
><export_customers_response>
>  <authentication>
>    <revision>2.0</revision>
>    <reseller_shortcut>eric</reseller_shortcut>
>    <user_email>test@test.com</user_email>
>  </authentication>
>  <customers>
>    <customer>
>      <customer_number>AC0127</customer_number>
>      <address_id>626</address_id>
>      <name>acme corp</name>
>      <address1>1234 lane ave</address1>
>      <address2 />
>      <address_line1>1234 lane ave</address_line1>
>      <address_line2 />
>      <city>powell</city>
>      <state>Ohio</state>
>      <state_abbrv>OH</state_abbrv>
>      <zip>43065</zip>
>      <country>United States</country>
>      <country_abbrv>USA</country_abbrv>
>      <phone />
>      <fax />
>      <website />
>      <lead_source />
>      <tax_exempt />
>      <tax_id />
>      <comments />
>      <terms>No Terms</terms>
>      <credit_limit />
>      <sales>
>        <name>Lundin, Eric</name>
>        <email>eric.lundin@cnet.com</email>
>        <price_profile>22% Mark-Up</price_profile>
>        <price_profile_email>channelsupport@cnet.com</price_profile_email>
>      </sales>
>      <billing>
>        <address_id>627</address_id>
>        <title />
>        <firstname>pat</firstname>
>        <lastname>leneghan</lastname>
>        <company>acme corp</company>
>        <address1>1234 lane ave</address1>
>        <address2 />
>        <city>powell</city>
>        <state>Ohio</state>
>        <state_abbrv>OH</state_abbrv>
>        <zip>43065</zip>
>        <country>United States</country>
>        <phone />
>        <extension />
>      </billing>
>      <shipping>
>        <address_id>627</address_id>
>        <title />
>        <firstname>pat</firstname>
>        <lastname>leneghan</lastname>
>        <company>acme corp</company>
>        <address1>1234 lane ave</address1>
>        <address2 />
>        <city>powell</city>
>        <state>Ohio</state>
>        <state_abbrv>OH</state_abbrv>
>        <zip>43065</zip>
>        <country>United States</country>
>        <phone />
>        <extension />
>      </shipping>
>      <contact>
>        <address_id>166722</address_id>
>        <title />
>        <firstname>pat</firstname>
>        <lastname>leneghan</lastname>
>        <company>acme corp</company>
>        <address1>1234 lane ave</address1>
>        <address2 />
>        <city>powell</city>
>        <state>Ohio</state>
>        <state_abbrv>OH</state_abbrv>
>        <zip>43065</zip>
>        <country>United States</country>
>        <phone />
>        <extension />
>        <home_phone />
>        <home_extension />
>        <fax />
>        <fax_extension />
>        <email>pleneghan@aol.com</email>
>        <mobile />
>        <mobile_extension />
>        <pager />
>        <website />
>        <other />
>        <other_extension />
>      </contact>
>    </customer>
>  </customers>
></export_customers_response>
>
>
>
>
>
>
>
>
Why do programs stop working correctly as soon as you leave the Fox?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform