Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To Use SAX With VFP7 ?
Message
From
03/05/2006 17:51:17
 
 
To
03/05/2006 12:34:42
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows Server 2003
Miscellaneous
Thread ID:
01118842
Message ID:
01118950
Views:
45
This message has been marked as a message which has helped to the initial question of the thread.
The XMLDOM is too slow when XmlToCursor() results is big... then I want to use SAX technique to parse XML. Is someone knows how to use SAX in VFP7? I would like to have complete example if possible. Thank you!

If you have a copy of MegaFox: 1002 Things You Wanted to Know About Extending VFP, there is an explanation snd sample class in Chapter 17:

How do I use the SAX interface to import XML? (Example: SAXImport.scx and SAXHandler.prg::VFPSAXHandler)

In order to use the SAX interfaces, you must be running Visual FoxPro 7 because previous version do not allow us to implement interfaces. For an in-depth discussion of interface implementation refer to Chapter 14, “VFP and COM”. The easiest way to begin creating a class that implements the SAX interface is to open the program file that contains the class definition and to open MSXML4.DLL in the object browser. We can then easily drag the interfaces that we need from the object browser into our program file and the methods defined in that interface are created for us automatically. All that remains is to write the required code in the appropriate methods.

One of the confusing things about the defined interfaces for MSXML4.DLL is that there seem to be duplicates. For example, there is an interface called ISAXContentHandler and there is another one called IVBSAXContentHandler. The reason for this is that SAX was originally defined for the Java programming language using Java interface definitions and these interfaces are not language–neutral. When Microsoft added support for SAX in MSXML 3.0, it included support for both C++ and Visual Basic. Each of these language bindings requires a different set of interfaces that reflect the individual language and type restrictions. So interfaces that are prefixed with ‘ISAX’ are the interfaces for C++ and those that begin with ‘IVBSAX’ are meant to be used in Visual Basic. When we implement these interfaces in Visual FoxPro, we need to use the interfaces that are supported in VB.

The SAX parser does not treat the XML document as a tree structure. Instead, it parses the document from top to bottom and as it does various events are fired. We can write method code to do specific processing when these events occur. For example, the StartElement event of the ContentHandler interface receives notification of the beginning of an element. So we can write method code here to do anything that needs to be done to process elements.
The sample form (Figure 17.2) uses the SAX interfaces and a data-driven approach to import customer orders from an XML document into three cursors.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform