Salesforce

How Do I Retrieve / Update /Insert Data According to a Certain Path in an XML Document? (Magic xpa 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Retrieve / Update / Insert Data According to a Certain Path in an XML Document? (Magic xpa 3.x)

If you are using the XML views to access an XML file, then you will work with the XML data source much as you would any other data source in a Magic xpa task. Using XML views is explained in How Do I Create an XML Doc from Scratch?.

However, you can also use XML functions to manipulate an XML I/O device.

Prerequisite: If you are going to update or insert data you have to be sure the file is open in write (not append) mode. Also, be aware that the syntax is slightly different if the data is an attribute or not.

For more information about formatting element path and attribute name, see How Do I Uniquely Identify a Data Element and Its Hierarchy Within an XML Document?. Also, these are fairly complex functions; see the Magic xpa Help for each function for more information.

Retrieving XML Data

XMLGet(generation, file, element path, attribute name)

  • generation is the task’s hierarchic position in the runtime task tree, 0 for the current task, 1 for the parent, and so on.

  • file is the sequence number of the I/O device that has the XML document.

  • element path is a string that uniquely defines one element in the path, as described below

  • attribute name is an attribute of the element, if any

Returns: If the function was successful, the function returns the data, as an alpha string. Otherwise, it returns an empty string.

Updating XML Data

The XMLModify() function allows you to modify elements in an XML file. The syntax is:

XMLModify(generation, I/O entry, element path, attribute, value [, auto convert])

  • generation is the task’s hierarchic position in the runtime task tree, 0 for the current task, 1 for the parent, and so on.

  • I/O entry is the sequence number of the I/O device that has the XML document.

  • element path is a string that uniquely defines one element in the path, as described below.

  • attribute is an attribute of the element, if any.

  • value is a string containing the data you want to change the element or attribute to.

  • auto convert is optional. If TRUE, then any characters that are invalid in XML are converted to placeholders.

Returns: Zero if the function was successful, an negative number otherwise. The error codes are listed in the Magic xpa Help.

Inserting XML Data

The XMLInsert() function allows you to add elements to an XML file. The syntax is:

XMLInsert (generation, I/O entry, element path, attribute, value [,before/after flag, reference element, auto convert])

  • generation is the task’s hierarchic position in the runtime task tree, 0 for the current task, 1 for the parent, and so on.

  • I/O entry is the sequence number of the I/O device that has the XML document.

  • element path is a string that uniquely defines one element in the path, as described below.

  • attribute is an attribute of the element, if any.

  • value is a string containing the data you want to add, or a Rich Edit BLOB.

  • before/after flag is optional, It is used with the reference element, to determine the placement of the new element.

  • reference element is optional. It is used with the before/after flag to determine the placement of the new element.

  • auto convert is optional. If TRUE, then any characters that are invalid in XML are converted to placeholders.

Returns: Zero if the function was successful, an negative number otherwise. The error codes are listed in the Magic xpa Help.

Deleting XML Data

The XMLDelete() function allows you to delete elements from an XML file. The syntax is:

XMLInsert (generation, I/O entry, element path, attribute)

  • generation is the task’s hierarchic position in the runtime task tree, 0 for the current task, 1 for the parent, and so on.

  • I/O entry is the sequence number of the I/O file that has the XML document.

  • element path is a string that uniquely defines one element in the path, as described below.

  • attribute is an attribute of the element, if any.

Returns: Zero if the function was successful, an negative number otherwise. The error codes are listed in the Magic xpa Help.

See also

The Online and Rich Client Samples projects (program XM16 and RXM16)

Reference
Attachment 
Attachment