# Copying XML input into a Message header and passing through the XML input to the output

**URL:** <https://community.cdata.com/t/copying-xml-input-into-a-message-header-and-passing-through-the-xml-input-to-the-output/742>\
**Category:** CData Arc\
**Tags:** question\
**Created:** [June 4, 2024, 1:13pm UTC](https://community.cdata.com/t/copying-xml-input-into-a-message-header-and-passing-through-the-xml-input-to-the-output/742 "2024-06-04T13:13:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![russell-jerseypost](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@russell-jerseypost](https://community.cdata.com/u/russell-jerseypost)\
**Post date:** [June 4, 2024, 1:13pm UTC](https://community.cdata.com/t/copying-xml-input-into-a-message-header-and-passing-through-the-xml-input-to-the-output/742/1 "2024-06-04T13:13:37Z")

</div>

Hi

I need to pass some XML through an XMLMap connector, but I also want to preserve the original XML input, for later use.

My thought was to do this in a script before it hits the XMLMap

 ![251c0d45-cf19-4ad8-b78d-90ed2f5d25ec.png](https://us1.discourse-cdn.com/cdata/original/2X/2/23b78a06f7091a1fc58de9e69f04a39d1798baf3.png)

But I don’t know how to

1. copy the Script connector input, straight out to the output
2. copy the&nbsp;Script connector input into a message header

Thoughts

---

<div class="post-metadata">

**Author:** ![russell-jerseypost](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@russell-jerseypost](https://community.cdata.com/u/russell-jerseypost)\
**Post date:** [June 4, 2024, 1:25pm UTC](https://community.cdata.com/t/copying-xml-input-into-a-message-header-and-passing-through-the-xml-input-to-the-output/742/2 "2024-06-04T13:25:12Z")

</div>

I think I’ve worked it out:

```xml
<arc:set attr="output.header:raworiginalorder" value="[_message.body]" /><arc:set attr="output.data" value="[_message.body]" /><arc:set attr="output.filename" value="[FileName]" /><arc:push item="output" />

```

---

<div class="post-metadata">

**Author:** ![James\_B](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/james_b/32/1688_2.png) [@James\_B](https://community.cdata.com/u/James_B)\
**Post date:** [June 4, 2024, 6:40pm UTC](https://community.cdata.com/t/copying-xml-input-into-a-message-header-and-passing-through-the-xml-input-to-the-output/742/3 "2024-06-04T18:40:51Z")

</div>

I see what you mean now. You could also do this directly in the XML Map with a Script step inside the XML Map:

 ![46ab8ad8-ddf8-40b3-9feb-129d7c1daf94.png](https://us1.discourse-cdn.com/cdata/original/2X/7/7a4297d9150c3c1286af88f6c2a783ce15f9549d.png)

The code here is:

```xml
<arc:set attr="_message.header:originalXML" value="[_message.body | regexreplace('>\s+<','><')]" />

```

Note that this regexreplace is meant to minify the XML if it’s not already minified (headers can’t be multiline values - you can also base64encode the content if you want to preserve whitespace), and that the body of the message isn’t fully loaded until after the first Foreach loop
