Add a field to an XML file

Post Reply
RunDontStop
Member
Posts: 51
Joined: Mon Apr 05, 2021 8:03 pm

Add a field to an XML file

Post 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?
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Add a field to an XML file

Post by jan_suhr »

Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
User avatar
magnussandstrom
Advanced member
Posts: 345
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: Add a field to an XML file

Post 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.
Post Reply