Use PHP to Append XML Node

Discussion in 'PHP' started by timallard, May 30, 2008.

  1. #1
    Hello,

    Im trying to append an XML node to an XML file through a PHP form...but im running into some trouble. I need it to append to the beginning.

    Can anyone help me out?
    I am running php 4.3.9.

    Example -


    PHP Form:
    Input Field 1 - Topic
    Input Field 2 - Name
    Submit Button - process.php


    XML File:
    <contacts>
    <entry topic="NEW APPENDED NODE" name="NEW APPENDED NODE">
    <entry topic="Science" name="Bob">
    <entry topic="Politics" name="Tim">
    </contacts>


    Any ideas?

    Thank you much!
    -Tim
     
    timallard, May 30, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Do you have the possibility of getting PHP 5? Using DOM would make your life SO much easier! Is that an option?

    Jay
     
    jayshah, May 30, 2008 IP
  3. timallard

    timallard Well-Known Member

    Messages:
    1,634
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    158
    #3
    Unfortunately it is not a possibility right now, ugh.
     
    timallard, May 30, 2008 IP
  4. chicagoweb

    chicagoweb Peon

    Messages:
    30
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It probably would be easier to upgrade to PHP5...
     
    chicagoweb, May 30, 2008 IP
  5. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #5
    :p If you want to press ahead, look up DOM. Or, if you want a quicker, perhaps easier, way, check explode and/or preg_replace.

    Jay
     
    jayshah, May 30, 2008 IP