Import form values from XML
Actions of type Set form fields form XML can be used to fill form fields with data from an XML document. This makes use of XPaths to select a value from the XML document.
Parameter
- XML source
- A previous action providing the XML document to be used.
- Select XSL template
- An optional XSL transform applied to the XML document.
- Values to be set (Set XPath)
- In the table, specific values from the XML document can be set for form elements.
- Field name
- Name of the form element to be changed.
- XPath
- XPath for selecting a value of the XML document. The value of the form field will be set to this value.
Example
To illustrate how this action works, consider the following XML:
<?xml version="1.0" encoding="UTF-8"?>
<xfc-data xfc-version="4.5.2" generation-date="2017-01-09 11:23:43.190 MEZ">
<processes>
<process process-uid="f1e677ad-012d-4586-884b-ac2ee029cb00" creation-date="2017-01-09 11:23:43.0 MEZ" project-name="XML" status="">
<form version="1">
<field name="upl1">
<plainValue><![CDATA[]]></plainValue>
<values count="0"/>
<label><![CDATA[]]></label>
</field>
<field name="tf1">
<plainValue><![CDATA[foobar]]></plainValue>
<values count="1">
<value index="0"><![CDATA[foobar]]></value>
</values>
<label><![CDATA[]]></label>
</field>
<field name="xf-action">
<plainValue><![CDATA[btnPrev]]></plainValue>
<values count="1">
<value index="0"><![CDATA[btnPrev]]></value>
</values>
<label><![CDATA[]]></label>
</field>
</form>
</process>
</processes>
</xfc-data>
<xfc-data xfc-version="4.5.2" generation-date="2017-01-09 11:23:43.190 MEZ">
<processes>
<process process-uid="f1e677ad-012d-4586-884b-ac2ee029cb00" creation-date="2017-01-09 11:23:43.0 MEZ" project-name="XML" status="">
<form version="1">
<field name="upl1">
<plainValue><![CDATA[]]></plainValue>
<values count="0"/>
<label><![CDATA[]]></label>
</field>
<field name="tf1">
<plainValue><![CDATA[foobar]]></plainValue>
<values count="1">
<value index="0"><![CDATA[foobar]]></value>
</values>
<label><![CDATA[]]></label>
</field>
<field name="xf-action">
<plainValue><![CDATA[btnPrev]]></plainValue>
<values count="1">
<value index="0"><![CDATA[btnPrev]]></value>
</values>
<label><![CDATA[]]></label>
</field>
</form>
</process>
</processes>
</xfc-data>
To select the value of the field named tf1, use this XPath:
//processes//field[@name="tf1"]/plainValue/text()