Xml/php

Discussion in 'PHP' started by one198, Aug 29, 2007.

  1. #1
    Hi guy

    Nowdays i am developing web site and i use to save data in XMl file.I use PHP also .So i dont know how to save PHP variables data in XML file.pls help me

    Thank you.
     
    one198, Aug 29, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Have a look at this page, and user comments below. There are some functions that will probably help. (Assuming you have PHP 5+)

    http://www.php.net/simplexml
     
    nico_swd, Aug 29, 2007 IP
  3. one198

    one198 Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi guys

    I think your link is more helpfull nico Swd.Thank you nico
     
    one198, Aug 29, 2007 IP
  4. one198

    one198 Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hi guys

    According to below PHP coding it's save data into name property of movie.The Problem is i need to save it has permanent data.But in here it,s not working

    pls help

    
    <?php
    $xmlstr = <<<XML
    <?xml version='1.0' standalone='yes'?>
    <movies>
    <movie>
     <title>PHP: Behind the Parser</title>
    <characters>
    <character>
    <name>Ms. Coder</name>
    <actor>Onlivia Actora</actor>
       </character>
       <character>
        <name>Mr. Coder</name>
        <actor>El Act&#211;r</actor>
       </character>
      </characters>
      <plot>
       So, this language. It's like, a programming language. Or is it a
       scripting language? All is revealed in this thrilling horror spoof
       of a documentary.
      </plot>
      <rating type="thumbs">7</rating>
      <rating type="stars">5</rating>
     </movie>
    </movies>
    XML;
    ?> 
    
    Code (markup):

    <?php
    include('XML.php');
    $xml = new SimpleXMLElement($xmlstr);
    
    $xml->movie[0]->characters->character[0]->name = 'Miss Coder';
    
    echo $xml->asXML();
    ?> 
    Code (markup):
     
    one198, Aug 29, 2007 IP