Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Writing to XML

  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Location
    AZ, USA
    Posts
    685
    Thanks
    6
    Thanked 46 Times in 46 Posts

    Writing to XML

    Quick question:

    Can you write to an xml file with the php fopen() and fwrite(), etc the same way as with a txt file?

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Pretty much yeah. Just make sure you add the xml declaration to the content and have it save as an .xml file.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    It's far easier to use SimpleXML for both reading and writing.

  • #4
    Regular Coder
    Join Date
    Sep 2007
    Location
    AZ, USA
    Posts
    685
    Thanks
    6
    Thanked 46 Times in 46 Posts
    On the simpleXML page:
    The SimpleXML extension requires PHP 5.

    My hosting plan has PHP4.

  • #5
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,036
    Thanks
    2
    Thanked 316 Times in 308 Posts
    The end of life of php4 is the end of this year. Your web host will be forced to upgrade of get left behind.

    They might already have php5 available, either through your control panel or through a statement in a .htaccess file. Check with them if and how you can switch to php5, or what their plan is to upgrade (this is not an "if" they are upgrading, but a "when" they are upgrading issue.)
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #6
    Regular Coder
    Join Date
    Sep 2007
    Location
    AZ, USA
    Posts
    685
    Thanks
    6
    Thanked 46 Times in 46 Posts
    Quote Originally Posted by CFMaBiSmAd View Post
    The end of life of php4 is the end of this year. Your web host will be forced to upgrade of get left behind.

    They might already have php5 available, either through your control panel or through a statement in a .htaccess file. Check with them if and how you can switch to php5, or what their plan is to upgrade (this is not an "if" they are upgrading, but a "when" they are upgrading issue.)
    Willdo! Thanks for your reply!


  •  

    Posting Permissions

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