Home
About
Search
Welcome to M-Files Empower – our new support experience. We'd love to hear what you think!Give feedback
Home/Support and troubleshooting/Examples and how to

How to use more than one xpath for a single property in M-Files external file sources

Last updated on 6 September 2024 · 2 min read

Admin

Overview

This article explains how to enter more than one xpath expression to read data to a single property and how M-Files behaves if more than one xpath expression is provided.

When using xml files as metadata for documents imported via an external file source, you may have a situation where the xml structure can contain the desired data in more than one node of the xml file and you don't exactly know in which node the data will be delivered for each individual document. In this case, the configuration needs the capability to look for the data with several xpath expressions.

Solution

In the file source's metadata configuration, you can enter more than one xpath expression for a single property by separating the expressions with the pipe character (|).

M-Files server will evaluate the expressions in the order that they have been defined in the configuration. It will pick up the value from the first matching node that it finds. All subsequent expressions are ignored.

Here are some examples. Let's suppose our xml looks like this:

<?xml version="1.0" encoding="utf-8"?>

  <Document>

    <Properties>

      <Customer>A</Customer>

      <Client>B</Client>

      <Purchaser>C</Purchaser>

    </Properties>

  </Document>

With the xml structure described above, we can configure M-Files to read each of the different data nodes with this expression:

/Document/Properties/Customer|/Document/Properties/Client|/Document/Properties/Properties

The pipe characters have been highlighted above for illustration purposes.

With this configuration, you would get the data as follows:

  • When all values A, B and C are provided in the xml, value A is picked.
  • When only values B and C are provided in the xml, value B is picked.
  • When only value C is provided in the xml, value C is picked.

For more details about using xml as metadata in file source configurations, please refer to the M-Files user guide.

Still need help?

On this page