www.webdeveloper.com
Results 1 to 5 of 5

Thread: Create .xml file in php

  1. #1
    Join Date
    May 2011
    Posts
    4

    Create .xml file in php

    I want to save this xml data in a separate .xml file in cakePHP but its not working. I used following code:

    $a="test";
    $b="mytest";
    $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
    $xml.= "<registrations>";
    $xml.= " <registration>";
    $xml.= " <id>".$a."</id>";
    $xml.= " <name>".$b."</name>";
    $xml.= " </registration>";
    $xml.= "</registrations>";
    $fh = fopen('my_xmls.xml', 'w+');
    fwrite($fh, $xml);
    fclose($fh);
    what is the problem in this code or please give me a new code.

  2. #2
    Join Date
    Aug 2006
    Posts
    1,906
    That looks fine, what's "not working" about it?

    Dave

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,322
    Does the actual code include the opening <?php tag?

    You may want to ensure all error reporting is on, or check the PHP error log to see if there are file write permission errors or such.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    May 2011
    Posts
    4
    OK.it's working.

    Thanks..

  5. #5
    Join Date
    May 2011
    Posts
    4
    I applaud you. Cheers to CakePHP!

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