Advanced XML rule example: Select node X if it exists and node Y if it does not
In this example, the expected value is normally found in a specific node, but if that node does not exist or is empty, you want Collector to take the value from another node. Example fields that you can look to for comparison are the TelephoneNumber, FaxNumber, and Email fields in a Svefaktura invoice.
- On the
of the XML Mapper (on the right side of the window), select the field
that the rule will apply to. (If this field does not exist or is empty, a value
will be extracted from a different node.)
- Click the button to the right of the
if no rule has been defined, or
if there is already an existing rule for the field.
- Click the button to the right of the value:
- Under XML node selection, navigate down to the parent node for both the expected value and the backup value, and click Select.
- Under XML node selected to work with, select the node for the expected value.
- Under Settings for new condition, select Node exists and click Add.
- Under Conditions to work with, select the condition that you just added.
- Under Settings to define how the invoice field value is set, select if condition is false.
- Select Use value from XML node and the secondary node in the box underneath it, and click Add.
- Select Use advanced rules.
Click Extract and review the image to check the results. If you need to modify the rule, you need to click it in the Rules applied to map this field box, click Del to delete it, make the changes needed to fix the rule, and click Add again to add the modified rule. If you need to modify a condition, the process is the same (and if a rule is based on it, the rule is also deleted if you delete the condition).
Consider if the change(s) should apply to all invoices or only those for the current XML invoice definition. Click Save XML definition to save the change for the current XML invoice definition only (that is, the current supplier). Click Save XML profile if you want the rule to apply to all XML invoices that match the XML invoice profile regardless of the XML invoice definition.