0

i tryed to do it with different codes but always with failure.

Here's my XML:

<movies>
  <movie>
    <title>Pav1</title>
    <plot>tekstas1</plot>
    </movie>
  <movie>
    <title>Pav2</title>
    <plot>tekstas2</plot>
  </movie>
</movies>

Here's the code i'm using:

<?php
  $xml = simplexml_load_file ( 'movies.xml' );
  $movies = $xml->addChild("movie");
  $movies->addChild("title", "title1");
  $movies->addChild("plot", "plot1");

  $xml->saveXML();
?>

Unfortunately, nothing happens after lounch. Thanks, for any advice.

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
wyy
  • 515
  • 2
  • 4
  • 18

1 Answers1

0

You did not include the original filename in the last statement. This should fix it:

$xml->saveXML( 'movies.xml' );
effulge
  • 77
  • 6