dcsimg
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
    2,034
    That looks fine, what's "not working" about it?

    Dave

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    21,430
    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.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  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