Salesforce

How Do I Export Data into an XML File? (Magic xpa 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Export Data into an XML File? (Magic xpa 3.x)

You can use the DataViewToXML() function to export data from your program into a text file. This function gives you, as the programmer, the most control over the export, so you can, if you choose, limit which records can be exported.

Using DataViewToXML()

DataViewToXML() will export the current data view, either in the current task or its ancestors. The syntax is:

DataViewToXML(Generation, VariableList, HeaderList, SchemaFileName, TemplateFileName, CharSet)

Where:

  • Generation is the task’s hierarchic position in the runtime task tree. Zero for the current task, 1 for the task’s parent, etc.

  • VariableList is a list of the variable names you want to export. This is the text name of the variable, as it appears in the Data View section of the task. The names are separated by commas (no spaces between variable names, and case matters).

  • HeaderList is a list of titles that will be used in the export file. In our example, we used “Studio Code” for the “Code” field, to make the output more readable. If the string is empty, no headers will be sent. If the string is ‘@’, the variable list will be used as the header list.

  • SchemaFileName (optional) is the name of the schema file that will be created. If it is blank, no schema will be created.

  • TemplateFileName (optional) is the name of the template file that will be used when creating the XML file.

  • CharSet is a number that sets the character set to be used: 0=ANSI, 1=Unicode, 2=UTF-8.

The result from our sample is shown below.

Creating a schema file

If you specify a schema file name in DataViewToXML(), a schema file will be generated.

Using an XML Template file

You can, if you want, specify an XML template file to format the XML. The template file needs to be an XSLT file, and it is used to format the XML.

See also

The Online and Rich Client Samples projects (program RP02 and RRP02)

Reference
Attachment 
Attachment