how to remove an xml node using php?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sakthiganapathy
    New Member
    • Oct 2007
    • 1

    how to remove an xml node using php?

    this is my php code:

    $dir=getcwd();
    $xmlDoc=$dir."/xml1.xml";

    $xdoc = new DOMDocument;
    $xdoc->validateOnPars e = true;
    $xdoc->Load($xmlDoc );

    $book = $xdoc->documentElemen t;

    $xp = new DomXPath($xdoc) ;

    $res = $xp->query("//*[@id = '".$id."']");
    //$chapter = $xp->getElementsByT agName('club')->item(0);
    $oldchapter = $book->removeChild($r es->item(0));
    echo $test = $xdoc->save($xmlDoc );

    i want to use query function also...

    plz help me...
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    What node are you trying to remove? What does your source xml look like? Why isn't it working as it is?

    Comment

    Working...