need urget help

Discussion in 'PHP' started by montyt, Jun 3, 2008.

  1. #1
    hi guys i need urgent help.. i am dead lock.. i need to finish this as soon as possible.

    my problem is:-
    flash > php > xml.
    #flash will read data from xml.
    1. flash will send data to php.
    2. php will convert/add data to xml.
    3. than from that xml flash will read data and display.

    its comment box, like message posting.

    I have succeeded up to making xml data from php. But the problem is each time php is adding data to xml. Its not adding data to next line. it is appending data to xml structure rather than adding data to next line.
    here is the php code
    <?php
    // create doctype
    $dom = new DOMDocument("1.0");
    
    // create root element
    $root = $dom->createElement("content");
    $dom->appendChild($root);
    $dom->formatOutput=true;
    
    //$senderName = $_REQUEST['namE'];
    //$commentAdded .= .$_REQUEST['comments'].;
    // create child element
    $item = $dom->createElement("contents");
    $root->appendChild($item);
    
    // create attribute node
    $price = $dom->createAttribute("namE");
    $item->appendChild($price);
    
    // create attribute value node
    $priceValue = $dom->createTextNode($_POST['namE']);
    $price->appendChild($priceValue);
    
    // create attribute node
    $address = $dom->createAttribute("comments");
    $item->appendChild($address);
    
    // create attribute value node
    $priceValue = $dom->createTextNode($_POST['comments']);
    $address->appendChild($priceValue);
    
    // save tree to file
    $dom->save("contacts.xml");
    
    //echo $commentAdded;
    // save tree to string
    $order = $dom->save("contacts.xml")."\n";
    ?> 
    PHP:
    what i need is. It should add data to current xml data structure. to the next line.

    realy i need urgent help. Please tell me how to achive this.

    i'll be very thank full to you.
    monty
     
    montyt, Jun 3, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    Check your apendchild, you are trying to add some information to an existing node, try to create a new one!
     
    EricBruggema, Jun 5, 2008 IP