Salesforce

How Do I Uniquely Identify a Data Element and Its Hierarchy Within an XML Document? (Magic xpa 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Uniquely Identify a Data Element and Its Hierarchy Within an XML Document? (Magic xpa 3.x)

If you are using an XML View to access an XML data source, you can access the elements just as you would columns in any other data source. You can view the hierarchy easily in the Data repository: see How Do I Create an XML Doc from Scratch?.

However, if you are using the XML functions, you need to specify the hierarchical path into the XML file.

For more information on these functions, see How Do I Retrieve / Update / Insert Data According to a Certain Path in an XML Document?.

Let’s take the XMLGet() function as an example.

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

Each element along the path is identified by its name, and an index (if it has multiple occurrences), separated by forward slashes. The last parameter is used for the attribute, if any.

Let’s take this XML snippet for an example:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

<Productions lastUpdate="2006-01-01" version="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >

<StudioList>

<Studio code="S004">

<name>Paramount</name>

</Studio>

<Studio code="S005">

<name>Warner Home Video</name>

</Studio>

<Studio code="S006 ">

<name>New Line Home Entertainment</name>

So for instance, to access the 3rd occurrence of the Studio code attribute, you would enter

XMLGet (0,1,

'/Productions/StudioList/Studio[3]','code')

Which would return ‘S006’

If you wanted to get the studio name element, the syntax would be:

XMLGet (0,1,

'/Productions/StudioList/Studio[3]/name', ‘’)

Which would return ‘New Line Home Entertainment’.

Usually, of course, the index would not be hardcoded, it would be a variable or some function such as LoopCounter().

See also

The Online and Rich Client Samples projects (program XM17 and RXM17)

Reference
Attachment 
Attachment