Page 1 of 1
Add a field to an XML file
Posted: Mon Nov 01, 2021 11:20 pm
by RunDontStop
I think this is possible but not sure how to set up. I am using XML pickup. Metadata is asset.
What I want to do is add an extra field (current date and time) and export a brand new XML, identical to the first but with this current data and time field added. How can this be done?
Re: Add a field to an XML file
Posted: Tue Nov 02, 2021 5:50 am
by jan_suhr
Re: Add a field to an XML file
Posted: Wed Nov 03, 2021 1:26 pm
by magnussandstrom
You can do this with the free app 'Create text file'.
Incoming XML:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<job>
<field_A>Hello</field_A>
<field_B>World</field_B>
</job>
The Content text in the 'Create text file-app' should be:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<job>
<field_A>[Metadata.Text:Path="/job/field_A",Dataset="Xml",Model="XML"]</field_A>
<field_B>[Metadata.Text:Path="/job/field_B",Dataset="Xml",Model="XML"]</field_B>
<field_C>[Switch.Date:Format="yyyy-MM-dd hh:mm",TimeZone="UTC"]</field_C>
</job>
Resulting XML:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<job>
<field_A>Hello</field_A>
<field_B>World</field_B>
<field_C>2021-11-03 12:25</field_C>
</job>
This approach of course requires the incoming XML to always have the same fields.