exchange >> XMLTOCURSOR help VFP8.0?

by John G » Wed, 19 Oct 2005 04:12:02 GMT

Hi,
I've tried everything I know and cannot get VFP 8.0 to read this XML. Can
anyone offer any suggestions.
I'm using XMLTOCURSOR, but the header is contained in the first record and
the last item is contained in record #2. Why does this command bypass all
the items and only process the last one (there are actually about 200 item
tags). Also, all the info is contained in one field. Do I need to upgrade
to VFP9
Thanks in advance,
John
Here is my code...

lcfilename = GETFILE("xml")
XMLTOCURSOR(lcfilename,"mhc_temp",512)
SELECT mhc_temp
BROWSE
USE inv_temp IN SELECT(1)
SELECT inv_temp
APPEND FROM DBF("mhc_temp")




<?xml version="1.0" encoding="ISO-8859-1" ?>
- <order>
- <header>
<ordernum>MHC000035783</ordernum>
<ponum />
<status>Closed</status>
- <billaddr>
<name>OBS</name>
<addr1>thens Rd</addr1>
<addr2>P O 999</addr2>
<addr3 />
<city>Cd</city>
<state>NY</state>
<zip>10563</zip>
<phone>7123982983</phone>
</billaddr>
- </header>
- <trailer>
- <item>
<num>10379</num>
<name>Bulbs 13W Cfl Mini Twist</name>
<mfgnum>BPESL13T</mfgnum>
<qty>2</qty>
<shipped>2</shipped>
<price>2.71</price>
<retail>5.39</retail>
<returned>0</returned>
</item>
- <item>
<num>10586</num>
<name>Tarpaulins 10X12 Blue Poly Tar</name>
<mfgnum>PT1012D</mfgnum>
<qty>2</qty>
<shipped>2</shipped>
<price>3.71</price>
<retail>7.39</retail>
<returned>0</returned>
</item>
- <item>
<num>10597</num>
<name>Tarpaulins 20X30 Blue Poly Tar</name>
<mfgnum>PT2030D</mfgnum>
<qty>1</qty>
<shipped>1</shipped>
<price>18.54</price>
<retail>37.09</retail>
<returned>0</returned>
</item>
- <item>
<num>10623</num>
<name>Blades V/A Hacksaw Blades</name>
<mfgnum>48236</mfgnum>
<qty>6</qty>
<shipped>6</shipped>
<price>.81</price>
<retail>1.69</retail>
<returned>0</returned>
</item>
<trailer>
<order>




exchange >> XMLTOCURSOR help VFP8.0?

by Thierry » Wed, 19 Oct 2005 05:03:13 GMT


i,

- Using StrExtract() and xmlToCursor() functions :

CLOSE TABLES all
cXml=FileToStr(lcFileName)

cXml2=StrExtract(cXml,"<order>","<billaddr>")
XMLToCursor("<vfpdata>"+cXml2+"</header></vfpdata>","header")
BROWSE nowait

cXml2=StrExtract(cXml,"<billaddr>","</billaddr>")
XMLToCursor("<vfpdata><billaddr>"+cXml2+"</billaddr></vfpdata>","billaddr")
BROWSE nowait

cXml2=StrExtract(cXml,"<trailer>","</trailer>")
XMLToCursor("<vfpdata>"+cXml2+"</vfpdata>","item")
BROWSE nowait


- You can also use XmlAdapter object
Example (to be completed)

LOCAL o as XMLAdapter
o=NEWOBJECT("XmlAdapter")
o.loadXml(lcfilename,.t.)

CREATE CURSOR Header (ordernum c(12),status c(10))
o.AddTableSchema("header",.t.,Strconv("header",12))
o.tables(1).ToCursor(.t.)
BROWSE nowait

CREATE CURSOR billaddr(name c(32), addr1 c(32), addr2 c(32))
o.AddTableSchema("billaddr",.t.,Strconv("billaddr",12))
o.tables(2).ToCursor(.t.)
BROWSE nowait

CREATE CURSOR item (num i,name c(32))
o.AddTableSchema("item",.t.,Strconv("item",12))
o.tables(3).ToCursor(.t.)
BROWSE nowait

--
Thierry


"John G" < XXXX@XXXXX.COM > a rit dans le message de
news: uY$ XXXX@XXXXX.COM ...



Similar Threads

1. VFP6 - VFP8 Issue or VFP8 Promlem?

Hi;

We have converted a couple of VFP6 apps to VFP8 with no real code changes. A 
couple of times we have come accross where, for example, a screen with a quit 
button (just 'release thisform' inside the valid clause) just does not do 
anything but you see it physically depress. You then have to ctrl+alt+del to 
leave the screen. Also a screen with a list box does not actually do anything 
either. We have come across similar scenarios when converting fpd2.6-vfp6 but 
it would be immediately upon conversion. We would then make a brand new 
screen using vfp6 buttons and all and just paste code. This is different in 
that the programs worked for months and then just "hickup". Has anyone else 
come across command buttons or list boxes not behaving properly under VFP8? 
Thanks.

TIA

Mike

2. HTML help in VFP8/9 - not working with app

3. Pinting in VFP8 - help needed

Following sample create different result in printer in both typeface & 
printing position.  Could someone tell me what ???"" actually did here & 
where I could find documentation about it (I know what help said about ???, 
but I can't find ???"")?

*Sample code*
SET PRINTER TO NAME GETPRINTER()
SET DEVICE TO PRINTER

SET CONSOLE OFF 
SET PRINTER on
?REPLICATE("ABCDEFGHIJKLMNOPQRSTUVWXYZ12345", 2 )
?REPLICATE("ABCDEFGHIJKLMNOPQRSTUVWXYZ12345", 2 )
?REPLICATE("ABCDEFGHIJKLMNOPQRSTUVWXYZ12345", 2 )
? ""
? ""
? ""

??? ""
 
?REPLICATE("ABCDEFGHIJKLMNOPQRSTUVWXYZ12345", 2 )
?REPLICATE("ABCDEFGHIJKLMNOPQRSTUVWXYZ12345", 2 )
?REPLICATE("ABCDEFGHIJKLMNOPQRSTUVWXYZ12345", 2 )
? "B"
? "B"
? ""

SET PRINTER OFF
SET CONSOLE ON
SET PRINTER TO


Thanks

4. VFP6 to VFP8 COM problem(HELP)

5. mega help needed with sp1 and vfp8.0

...is it possibile to uninstalle the sp1 of vfp8.0???
my exe is not working with it even if i recomile my project...
help please...


6. Help distributing and app (VFP8)

7. VFP8, Frontpage and Help 1.4SDK

8. Problem with XML Code in VFP8.0