Results 1 to 2 of 2

Thread: write XML Dates with PHP

  1. #1
    Join Date
    May 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool write XML Dates with PHP

    Hi everybody !

    i have a problem. I want to write more data to xml file without the new data overwrites the old data. Help me.

    code php:
    PHP Code:
    <form name="frmXML" method="post" action="xml.php">
    First name <input type="text" name="txtFirstName">
    Last name <input type="text" name="txtLastName">
    <input type="submit" name="submit" value="click">
    </form>
    <?php
        
    //get value to form
        
    $firstname $_POST['txtFirstName'];
        
    $lastname $_POST['txtLastName'];
        
        
    // create xml document
        
    $xmldoc = new DOMDocument();
        
    $xmldoc->formatOutput true;
        
        
    // create root nodes
        
    $root $xmldoc->createElement("RESUMEDATA");
        
    $xmldoc->appendChild$root );
        
        
    // create element nodes
        
    $elem $xmldoc->createElement("RESUME");
        
        
    //
        
    $fname $xmldoc->createElement("FIRSTNAME");
        
    $fname->appendChild($xmldoc->createTextNode($firstname));
        
    $elem->appendChild$fname );
        
    //
        
    $lname $xmldoc->createElement("LASTNAME");
        
    $lname->appendChild($xmldoc->createTextNode($lastname));
        
    $elem->appendChild($lname);
        
        
    //create end root nodes
        
    $root->appendChild($elem);
        
    //save file
        
    $xmldoc->save("write.xml")
    ?>
    code XML:

    HTML Code:
    <?xml version="1.0"?>
    <RESUMEDATA>
      <RESUME>
        <FIRSTNAME>data1</FIRSTNAME>
        <LASTNAME>data1</LASTNAME>
      </RESUME>
      <RESUME>
        <FIRSTNAME>data2</FIRSTNAME>
        <LASTNAME>data2</LASTNAME>
      </RESUME>
      <RESUME>
        <FIRSTNAME>data3</FIRSTNAME>
        <LASTNAME>data3</LASTNAME>
      </RESUME>
    </RESUMEDATA>
    send to email: tuan091286@gmail.com
    Thanks a lots
    Last edited by NgTuan; 05-11-2010 at 06:17 PM.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Moved to a new thread. This was posted in another topic.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •