dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: Creat xml by php

  1. #1
    Join Date
    Apr 2010
    Location
    Cairo,Egypt
    Posts
    33

    Creat xml by php

    hello
    i'm trying to create xml file by using php 5, and i have some problems with functions which i use , so i want a sample code to create xml file .
    thank you

  2. #2
    Join Date
    Apr 2010
    Location
    Cairo,Egypt
    Posts
    33
    Quote Originally Posted by ragy View Post
    hello
    i'm trying to create xml file by using php 5, and i have some problems with functions which i use , so i want a sample code to create xml file .
    thank you
    i tried the following code :
    <?php
    $document =new DomDocument('1.0');
    $rootElement = $document->createElement("root");
    $new_node = $document->appendChild($rootElement);
    $itemsElement = $document->createElement("Items");
    $items_node = $new_node->appendChild($itemsElement);

    for($i = 0; $i < 5; $i++) {
    $item = $document->createElement("Item");
    $item = $document->createTextNode("This is item $i");
    $items_node->appendChild($item);
    }
    $document->dump_file("test.xml", false, true);
    ?>

    but it make error at the last line code with the function
    $document->dump_file

    thank you
    and i donne know what the problem ac

  3. #3
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    That's because there is no such method as dump_file. Try "save" .

    http://www.php.net/manual/en/domdocument.save.php
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  4. #4
    Join Date
    Apr 2010
    Location
    Cairo,Egypt
    Posts
    33
    hello again
    thank you , i tried it and it works .
    thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles