Guest User

Untitled

a guest
May 16th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1. <?php
  2. $doc = new DOMDocument();
  3. $doc->load( 'things.xml' );
  4. $doc->formatOutput = true;
  5.  
  6. if( $_POST['clear'] ){
  7.   $thingset = $doc->getElementsByTagName("thingset")->item(0);
  8.   $new = $doc->createElement('thingset');
  9.   $doc->documentElement->replaceChild($new, $thingset);
  10. }else{
  11.   $thing = $doc->createElement('thing');
  12.   $text = $doc->createTextNode(htmlentities($_POST['thing']));
  13.   $thing->appendChild($text);
  14.   $doc->getElementsByTagName("thingset")->item(0)->appendChild($thing);
  15. }
  16.  
  17. $doc->save( 'things.xml' );
  18.  
  19. header( 'Location: things.php' );
  20.  
  21. ?>
Add Comment
Please, Sign In to add comment