Build an XML file

Hi all,

it is maybe an simple topic but i have not found an solution... maybe i have not read very well the doc...

i need to build an xml file that have this structure:

<?xml version="1.0" ?>
  <pcis:PCISDocument xmlns:picsis="urn:global:pcis:xsd:1" xmlns:ns1="r" schemaVersion="1.5" creationDate="2016-11-08T09:52:55.075Z">

i can build the as an array of objects like this:


but i need to add <eventTime> , <bizLocation> (variable) and <action> and <bizStep> (static).
tried a few methods by replacing, joning, ... but none was successful is there any "simple" way to combine with node red?


One approach would be to take that example XML and pass it through the XML node to get it's JavaScript object equivalent. That will give you a structure to aspire to so that the XML node will convert it back the other way to get the result you want.

1 Like

Hi Nick,

thanks for the idea with the xml node... unfortunately the resulting structure is pretty complex and i do not know how to build it ...(tried but no real result ...)

any suggestion ... ?

you could get a head start by doing this...

  1. in the debug window, click the payload item - then click the middle icon on the right

  2. in an inject node (set for JSON), then paste what you copied. (you can edit out values you dont want/or need)

    That will give you the structure that you can use as a starting point.

  3. wire that inject to a function node 9or change node if you wish) to edit / replace parts etc.


inject JSON (pasted JSON) --> change node --> XML --> debug node

Hi Steve,

i am not sure i get it ...

my problem is to get an array of objects of an array of objects of an can i build an loop that give me such an structure .... ?

Did you try what I said?

Once you have a base object you can add and remove parts of it THEN transform back to XML ready to generate an XML file

isn't that your final goal here?

I do realise an inject might not be what you want or need in the end - but to get started, do that.

Once you have a handle on playing with static data (adding array elements etc) then you can migrate what you learn into an automated solution.

Anyone can show you how to do a loop. But you can't even build the required object....

So, I'm trying to help you break this huge seemingly insurmountable problem into small solvable tasks.

Hi all,

thanks for your suggestions. Finaly i solved as recommended by cutting in small pieces :slight_smile: ... even if that (it should be an interface ...) is not needed any more ... well i see it as learning... wow! what an tool... Thanks to all that are helping to develop such an tool.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.