SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: XML Help

  1. #1
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    XML Help

    I'm trying to learn how to use XML.. but stuck at the beginning. Here is what I have so far:

    The PHP code is..

    PHP Code:
    $xml = new SimpleXMLElement(file_get_contents('xml/data.xml'));
                
                
    $script $xml->addChild('script');
                foreach (
    $clean as $k=>$v)
                {
                    
    $script->addChild($k$v);
                } 
    Now how do I write $xml back to the file?

  2. #2
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if ($xml->asXML('xml/data.xml')) echo "File written!"

  3. #3
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Cool thanks. Anyway to format this like a proper XML file?


Bookmarks

Posting Permissions

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