Description
PowerBuilder supports both the export and import of XML in DataStore and DataWindow objects using XML template objects. You construct XML templates for export and import graphically in the Export/Import Template view for XML. Each template you create is encapsulated in the DataWindow object. A template enables you to specify the XML logical structure of how the row data iterates inside the root element of the XML document.
Usage
When you create a new DataWindow object, PowerBuilder displays a default template in the Export/Import Template view. The default template has one element for each column in the DataWindow object.
An XML export template lets you customize the XML that is generated.You can specify optional XML and document type declarations that precede the root element in the exported XML, as well as the logical structure and nesting level of iterative DataWindow row data inside the root element. The children of the root element can contain elements, character references, and processing instructions as well as the row data. If the exported XML is used by different applications or processes, you can define a separate export template for each use.
You can export the data in a DataWindow or DataStore object to XML using any of the techniques used for exporting to other formats such as PSR or HTML:
- Using the SaveAs method:
ds_1.SaveAs("C:\TEMP\Temp.xml", XML!, TRUE)
- Using PowerScript dot notation or the Describe method:
ls_xmlstring = dw_1.Object.DataWindow.Data.XML ls_xmlstring = dw_1.Describe(DataWindow.Data.XML)
- Using the Save Rows As menu item in the DataWindow painter when the Preview view is open. You can use this at design time to preview the XML that will be generated at runtime.
You can import data from an XML document with or without an XML template using the Rows>Import menu item in the DataWindow painter or the ImportFile, ImportString, and ImportClipboard functions. You need to create an import template if you want to import data that does not match the DataWindow column definition or is associated with a schema, or if you want to import attribute values.Only the mapping of column names to element and attribute names is used for import. All other information in the template is ignored.
|