XML Functionality Using XMLAdapters

Visual FoxPro enhances its existing XML features and its compatibility with XML DiffGram and .NET Framework ADO.NET DataSet formats by providing the XMLAdapter, XMLTable, and XMLField classes. With these classes, Visual FoxPro supports hierarchically formatted XML for the following:

  • XML files that have associated schema, either inline or external, as implemented by ADO.NET DataSets based on the .NET Framework. For more information, see ADO.NET DataSets.

  • Microsoft XML Data Reduced Schema (XDR) as used by Microsoft SQL XML

  • ADO Recordset schemas that are produced when an ADO Recordset is saved as XML to a file or stream

Visual FoxPro can factor an XML file representing a collection of different and possibly related tables, such as an ADO.NET DataSet object, into separate Visual FoxPro cursors. Usually, this file contains data from a database management system (DBMS) with the structure of Parent > Child > Child. The XML can also have a nested format such as Parent > Child, Parent > Child, or a serial format such as Parent-Parent, Child-Child.

When you have hierarchical XML that represents a single table resulting from a multiple-table SQL JOIN command, Visual FoxPro creates only one cursor.

Note

The XMLAdapter, XMLTable, and XMLField classes require Microsoft XML Core Services (MSXML) 4.0 Service Pack 1 (SP1). For more information about these classes, see XMLAdapter Class, XMLTable Class, and XMLField Class. For more information about MSXML, see Microsoft XML Core Services 4.0 SP1 on the MSDN Library Web site at https://msdn.microsoft.com/downloads/.

Note

XML Schema Definition (XSD) schema as generated by Visual Studio ADO.NET DataSets might contain elements not supported by Visual FoxPro. For more information, see Support for Schemas Generated by ADO.NET DataSets.

ADO.NET DataSets

In the .NET Framework, ADO.NET is a set of classes that expose data access services to the programmer. ADO.NET provides consistent access to data sources such as Microsoft SQL Server and other data sources exposed through OLE DB and XML.

The ADO.NET DataSet is used as the primary class for manipulating data and encapsulates data as XML. An ADO.NET DataSet object can produce XML in several ways:

  • By returning the entire ADO.NET DataSet to the calling application.

    This method returns all rows in the original query in XML DiffGram format with inline schema and update, insert, and delete operations as indicated. Rows that remain unchanged do not have the diffgr:hasChanges attribute.

    When a DataSet object returns to the calling application from a method in an application that uses the .NET Framework and returns ADO.NET DataSet objects, it is always serialized, or converted, into XML. Visual FoxPro can convert this XML into cursors, which you can then manipulate in a Visual FoxPro application.

  • By returning only changes to the ADO.NET DataSet to the .NET-based application.

    This method returns only those rows, in XML DiffGram format, that were modified, added, or deleted.

    If the ADO.NET DataSet object contains changes, they are marked with the attributes, DiffGram:hasChanges="modified" or DiffGram:hasChanges="inserted". For those records marked as "modified", the previous values appear in the section, diffgr:before. Records that are deleted appear only in the diffgr:before section and not in the main section of the DiffGram.

  • By using the ADO.NET DataSet GetXml and GetXMLSchema methods to return XML as a .CLR stream or string type.

  • By using the ADO.NET DataSet WriteXml and WriteXmlSchema methods to write the ADO.NET DataSet as XML to a file with inline schema, without schema, or separate schema.

For more information about XML DiffGram and ADO.NET DataSet formats, see the .NET Framework SDK on the MSDN Library Web site at https://msdn.microsoft.com/library/.

Support for Schemas Generated by ADO.NET DataSets

XML that has external or inline XML Schema Definition (XSD) schema as generated by ADO.NET DataSets might contain elements not supported by Visual FoxPro, which disregards those elements. For example, these elements might include the following:

  • xs:unique name

  • xs:annotation

  • Additional processing instructions and attributes such as the following:

    • Schema prefix support, such as msdata:Prefix, that defines the scope of a group of elements

    • XML prefix support, such as the vfpx attribute, that scopes the prefix to root elements

    • msprop attribute and other attributes that use this namespace

    • Other msdata attributes that reference items not supported by Visual FoxPro, such as msdata:Locale or msdata:Comment

See Also

Reference

Visual FoxPro and XML Schema Data Type Mapping

Concepts

XML Data in Visual FoxPro
Converting Between XML and Visual FoxPro Data

Other Resources

Importing and Exporting Data