www.webdeveloper.com
Results 1 to 2 of 2

Thread: removeChild

  1. #1
    Join Date
    Nov 2008
    Posts
    61

    removeChild

    Hi! I need help with removeChild function.
    This is my xml file:

    <ROOT>
    <RT xml:id="1">
    <str name="title">aaaa</str>
    <str name="date">aaaa</str>
    </RT>
    <RT xml:id="2">
    <str name="title">aaaa</str>
    <str name="date">aaaa</str>
    </RT>
    <RT xml:id="3">
    <str name="title">aaaa</str>
    <str name="date">aaaa</str>
    </RT>
    </ROOT>

    I need to remove RT node (not all RT node, only RT with a specific id, for examlpe id=2) and it's child.
    I use this code to remove RT child but I'm unable to remove parent (RT with id=2). Help please..
    $elem = $xml->getElementById($idElement);
    $num = $elem->childNodes->length;
    for ($k = 0; $k < $num; $k++)
    {$childNode = $elem->removeChild($elem->childNodes->item($k));}
    $xml->saveXML();

  2. #2
    Join Date
    Nov 2008
    Posts
    61
    any idea??

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles