# Append XML after root tags

**URL:** <https://forum.kirupa.com/t/append-xml-after-root-tags/260078>\
**Category:** Uncategorized\
**Created:** [May 12, 2008, 1:33pm UTC](https://forum.kirupa.com/t/append-xml-after-root-tags/260078 "2008-05-12T13:33:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyleAS](https://avatars.discourse-cdn.com/v4/letter/k/51bf81/32.png) [@kyleAS](https://forum.kirupa.com/u/kyleAS)\
**Post date:** [May 12, 2008, 1:33pm UTC](https://forum.kirupa.com/t/append-xml-after-root-tags/260078/1 "2008-05-12T13:33:57Z")

</div>

Problem: I recieve XML from my flash document, and I write it to the XML document that works fine but I am having troubles keeping a root XML tag.

Here is my code.

Question: should I parse the document and write after the tag I want? and if so how do I go about doing that…

Thank you.

```php
<?php

$filename = "xml/messages.xml";
$raw_xml = file_get_contents("php://input");

print $raw_xml."
";
urldecode($raw_xml);
$fp = fopen($filename, "a+");
fwrite($fp, $raw_xml);
fclose($fp);
?>

```
