problem with line: $toreserve->addChild('child');

Discussion in 'PHP' started by apampe, Oct 2, 2007.

  1. #1
    I'm tring to simply add a child element to a xml file. I new to php and feel like I'm making a stupid mistake with simplexml or php. The line $toreserve->addChild('child'); locks up the script. if you comment it out, the script will complete printing periods for all "air" elements.

    foreach ($xml->xpath('//air') as $toreserve){ //there's about 10 of them
    echo ".";
    //if ($toreserve['dispName'] == $_GET["item"]){
    $toreserve['dispName'] = "mwahaha";
    $toreserve->addChild('child');
    //}
    }


    Please help... is $toreserve->addChild('child'); incorrect because of a variable type issue, or do i likely not have some portion of php installed? without the addChile line, I can then have it write the edited xml to file.

    Thanks,
     
    apampe, Oct 2, 2007 IP
  2. sdemidko

    sdemidko Member

    Messages:
    81
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    what kind of error do you see?
     
    sdemidko, Oct 2, 2007 IP