Skip to main content

XML File

The XML file provider is a read-only provider where you specify the data schema via XPath expressions.

Below is a sample XML file you can read with this provider there are a few things to note:

  • Each product is a child element of products
  • The id of the product is an xml attribute value of product.
    <products>
<product id="1">
<name>product1</name>
<price>123.45</price>
</product>
<product id="2">
<name>product2</name>
<price>456.78</price>
</product>
</products>

The XPath to the product child nodes is either products/product or //product The XPath to the product id is @id and the XPath to name and price are name and price as they are elements of the product (current) node.

These XPath expressions then translate the XML document into a Table structure for Data Sync to use.

XPath documentation on MSDN https://msdn.microsoft.com/en-us/library/ms256471(v=vs.110).aspx

Connect

To connect to an XML file, open the connection window and expand the XML folder. Select the XML File provider option and then click onto the ellipsis in the XmlDocumentUrl field to open the file explorer. You then need to browse for your file and click OK to load it into the connector.

Connect to XML File

You now need to specify the columns to load, these are the XML nodes found within your XML document that hold the data. To do this click onto the ellipsis in the Columns field to open the collection editor. You can see an example configuration for the ID and name columns below:

Column Example ID

Column Example Name

The next step is to specify the XPath to each item in the XML document in the XmlItemElementXPath. Using the example from above we use //product. To finish connecting click Connect and the file will be loaded into the datasource window.

Connect XML File

You can then add the columns to the schema map and preview the data by clicking Preview A in the schema map window.

Connect to XML File Preview Result

You are now ready to configure your target to synchronise this XML data to.

Properties

Below you can read more information on each of the properties in the XML File connector.

XmlDocumentUrl

The file path or Web Url to the XML file to load.

info

Windows Wildcards are supported in the filename i.e. *.xml.

XmlItemElementXPath

The XPath expression to the node item collection e.g. /products/product or //product

Namespaces

If you need to register XML Namespaces for your document you can add XML Namespaces and prefixes in this collection.

Columns

Use the Columns collection to specify the columns Name, DataType, and XPath Expression. Please note that XML XPath expressions are case-sensitive.

Below you can find the configuration for each of the columns used in the example shown previously.

ID Column Name Column Price Column

SearchInFolders

When using Wildcard filenames this specifies whether the search will include subfolders.

__SourceFileName

This is a special column that is injected into your schema and will return the filename of the XML document. This is especially useful when using wildcard filenames.