XML data source
An XML data source asset allows you to show information from an XML source within your site. Each record in the XML source will be displayed as a shadow asset in the asset tree. You can then use the tools within Matrix, such as an asset listing, to display this information in your site.
Once you have created your XML data source, you can configure the asset on its associated screens. Many of these screens are similar to a standard page. They are described in the Asset screens documentation.
Read the DB data source documentation for more information on the Record filter screen.
This chapter will only describe the Details and Dynamic inputs screens, which are different for an XML data source.
The Details screen allows you to configure the XML data source.
Read the Asset screens for more information about the Status, Future status, Thumbnail, and Details sections of the Details screen.
This section allows you to set up the XML data source.
The fields available are as follows:
- Link for the XML feed
Enter the hyperlink for the XML feed.
- Root tag
Enter a tag from which to start reading the XML feed. If nothing is specified, the entire XML feed will be parsed for the tags that have been specified in the Tag names field.
- Tag names
Enter a comma-separated list of tags you would like to use from the XML feed.
Any data to be extracted should be in the same tree level on the XML feed as specified in this field. Xpath-like syntax is also supported here to extract tags specified by a particular path, for example, user/department/id.
- Cdata tag names
Enter a comma-separated list of tags you would like to use from the XML feed. These tags will be wrapped in an undefined character data (CDATA) section and must already be defined in the Tag names field.
- Data delimiter
Enter a character to use as the data delimiter. This character will be used to separate XML elements that have the same name. By default, this is set to
Once you have entered the details into these fields and clicked Save, shadow assets will appear in the asset tree under the XML data source.
Each shadow asset represents one item from the XML feed.
Read the Shadow assets documentation for more information on shadow assets.
Consider the following XML feed:
<books> <title>List of books</title> <recid>cat1</recid> <book> <recid>item1</recid> <title>The Dead Zone</title> <author>Stephen King</author> </book> <book> <recid>item2</recid> <title>The Murder of Roger Ackroyd</title> <author>Agatha Christie</author> </book> </books>
If you set the tag names value to book/title or books/book/title, the data records returned will be:
- Record 1
The Dead Zone
- Record 2
The Murder of Roger Ackroyd
If you set it to books/title, it will return:
- Record 1
List of books
The tag attributes section allows you to return attributes of specified tags exposed on the XML data source.
The tags exposed on the XML data source will be displayed in the Select tag attributes field. In the corresponding attributes field(s), enter the tag attributes names to return.
The shadow asset name section allows you to specify the name of the shadow assets that appear under the XML data source in the asset tree and provide a list of available keyword replacements for these assets.
In the Enter the name of the shadow asset field, enter the name used for shadow assets exposed by the XML data source.
This name can either be a standard string or a combination of a string and keyword replacements.
For example, the keyword replacement
%data_source_record_set_result% could be used to display the result data of the returned records as the names of your shadow assets.
A list of keyword replacements is displayed in the Available keywords for the data source record set asset field, exposing the attribute values of the shadow assets returned on the XML data source. These keyword replacements can be used when defining the shadow asset name format and to print XML data on a site, for example, using an asset listing page.
|The keyword replacements listed in the available keywords for the Data source record set asset field will differ depending on the record attributes returned on the XML data source.|
This section allows you to specify an XSL file for extensible style sheet language styling of the XML data file source content when previewing the asset.
This option requires PHP to have XSL support supplied in your system.
If your system runs on Debian, you will be required to install the
In the XSL transformation field, select an XSL file to use and select Save. The XSL file will now be used to stylize the source content of the XML data source. This style will be reflected when previewing the asset on the Preview screen.
The Dynamic inputs screen allows you to use dynamic parameters within the XML feed URL.
This section allows you to add variable names for the parameters that you want to add.
To add variable names:
Enter the variable name into the Name field.
Enter the default value into the Default value field.
The variable will be added to the list, as shown in the figure below.
Once you have added a variable, you can set it up within the data mappings section.
To delete a variable:
Click the Delete box.
To use the variable within the XML feed URL, add double-percentage signs (
%%) around the variable name.
For example, if the variable’s name is variable, add
%%variable%% within the XML feed URL.
Variable names are case sensitive, so for example,
variable is not the same as
This section allows you to set up the dynamic variables that have been added in the section above.
Select which variable to edit from the parameter list and select a source from the source list. The options available in the data mappings section are similar to those available in the dynamic section of the Details screen of an asset listing page.
Read the Asset listing documentation for more information on these options.