# Xml update using php

**URL:** https://forum.kirupa.com/t/xml-update-using-php/176518
**Category:** Uncategorized
**Created:** [January 24, 2006, 6:47pm UTC](https://forum.kirupa.com/t/xml-update-using-php/176518 "2006-01-24T18:47:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![skyler](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@skyler](https://forum.kirupa.com/u/skyler)
#### Post date: [January 24, 2006, 6:47pm UTC](https://forum.kirupa.com/t/xml-update-using-php/176518/1 "2006-01-24T18:47:47Z")

</div>

This code works, but it only replaces the XML already written with new XML, I dont want to replace old XML, I want to add new. Anyone know how I might create new xml, rather than replace?

I have this code:

```php
<?php 

// set name of XML file 
$file = "usethis.xml"; 

// load file 
$xml = simplexml_load_file($file) or die ("Unable to load XML file!"); 

// modify XML data 
$xml->parent->name = $_POST['name']; 
$xml->parent->words = $_POST['words']; 

// write new data to file 
file_put_contents($file, $xml->asXML());

include("usethis.xml");
?> 

```
