Skip to main content
Version: 11.x

XML

The XML datasource allows you to display data from an XML source in Smartsign.

This makes it possible to integrate data from external systems, APIs, or internally published XML files into your digital signage content.

XML (Extensible Markup Language) is a structured data format commonly used to exchange information between systems.
It organizes data in a hierarchical structure, which makes it possible to extract and display individual values on screens.

alt text

info

This datasource is intended for users with basic technical knowledge of XML and XPath.
While powerful, it may be more complex to configure compared to other datasources.

How it works​

When connected, Smartsign retrieves XML data from the specified source URL and makes it available in the Template Creator using XPath expressions.

The XML data can be fetched either:

  • Via the Smartsign server (default, cached for performance and security).
  • Directly from the source by the screen or player, depending on your configuration.

The retrieved data can then be databound to text or other elements in a template.

Requirements​

To use the XML datasource, you need:

  • An accessible XML source available over HTTP or HTTPS.
  • The XML source must be encoded in UTF-8
  • Basic technical knowledge of XML and XPath for configuring data bindings.

If you plan to use direct requests, the XML source must also support browser-based access and comply with standard CORS rules.

Set up the datasource​

The first step is to configure your data source with the XML source you want to use.

In this example we will use a basic URL without any request headers or requirements, but you can read more about them in the configuration details below.

The URL should look like something like this: https://server.example.com/data.xml

  • Go to Templates -> Datasources and select Add datasource -> Create new. alt text
  • Select the XML datasource.
  • Configure the datasource by adding Name, Description and XML link. Use Users & Groups to choose who can add the datasource to a template. You can also select a Custom Icon (optional) to make it easier to recognize. alt text
  • Click Create. Smartsign fetches example data automatically. alt text
  • Check Status for Data fetched to confirm that data was received.

Datasource is now ready to be used.

Identifying XPath expressions​

Before creating the template, you need to identify the XPath expressions required to fetch data for each field.

XPath is used to tell Smartsign where in the XML structure a specific value is located. An XPath expression describes the path from the root of the XML document to the element you want to display.

Each level in the XML hierarchy is separated by a /.

Example structure

<root>
<ads>
<estate>
<price>€ 989,000</price>
<street>176 Hillview Sidings St.</street>
<property-type>Single family residence</property-type>
<description>Property description text</description>
</estate>
<images>
<url>https://server.example.com/property.jpg</url>
</images>
</ads>
</root>

How to find the Xpath​

  1. Start at the root element. In this case, the root element is <root>.
  2. Follow the structure down to the value you want. Each nested element becomes part of the path.
  3. End with the element containing the value.
    root/ads/estate/price will result in € 989,000

Xpath examples

FieldXpathResult
Street address/root/ads/estate/street176 Hillview Sidings St.
Price/root/ads/estate/price€ 989,000
Property type/root/ads/estate/property-typeSingle family residence
Description/root/ads/estate/descriptionProperty description text
Image/root/ads/images/urlhttps://server.example.com/property.jpg
tip

Common tips

  • XPath is case-sensitive
  • Element names must match exactly as they appear in the XML
  • If your XML contains namespaces, enabling Remove namespace definitions removes namespace declarations and may simplify XPath usage
  • Start simple and bind one field first and verify the output before adding more

Create an XML template​

An XML template can either be created from scratch, or you can download a suitable template from the Marketplace and adapt it to your needs. If you are new to templates, please see the Template Creator guide to learn the basics.

  • Create or download templates from the Templates menu. alt text

  • Open the template and add text fields and image placeholders for the Xpath data.

  • In Template settings, expand Datasources and click Connect new datasource. Select your XML datasource and click Connect.

  • Under Data binding, select XPath value for text or XML - Image for an image placeholder, then enter the corresponding XPath expression. alt text The Select XPath from test data option helps you identify the correct XPath when binding fields.

    • Street Address ./root/ads[(iterator(20))]/estate/street
    • Property type ./root/ads[(iterator(20))]/estate/property-type
    • Description ./root/ads[(iterator(20))]/estate/description
    • Price ./root/ads[(iterator(20))]/estate/price
    • Image ./root/ads[(iterator(20))]/images[(iterator(20))]/url

You can also bind a text field to Last update time. XPath value has Strip HTML tags enabled by default. Enable Parse date to select a Date format; a value that cannot be read as a date is shown unchanged.

Click Save when the template is ready.

What is the iterator?​

The iterator is used when your XML feed contains multiple items and you want to display them one at a time.

In the examples above, the value 20 specifies how many seconds each item is shown before switching to the next. It is important that all XPath expressions use the same iterator value to keep the content in sync.

If you want to display a single object or select a specific item from a list, you can use an index instead.

./root/ads[0]/estate/street selects the first item from the list.

Technical information​

XML source must be encoded in UTF-8

XML datasource configuration options​

Set XML link, Custom request headers and Use direct request on the datasource. Set Data update time and Remove namespace definitions in Template Creator under Datasource settings for this template.

Setting

Description

Example

XML link

The full URL to the XML source, including protocol (HTTP/HTTPS).

https://server.example.com/data.xml

Data update time

Time in seconds between updates. Default: 3600 seconds.

Restrictions (regardless of set value)
Server requests: 5 minutes
Direct requests: 2 seconds

3600

Custom request headers

HTTP header key and value pairs

Key = Authorization
Value = Bearer XyzXyzXyzXyz

Use direct request

Enable to request data direct from source instead of proxying through Smartsign Server

Server fetched data is cached by the server for 10 minutes for load balancing and security.

Direct fetched data is subject to browser security rules
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

False
Remove namespace definitions Enable to remove namespace declarations from the XML. Off by default. Prefixed element names are not changed.
This may help if you have trouble getting data from your Xpaths.
True