Loading ...
Sorry, an error occurred while loading the content.

Removing node from the xml by SimpleXML

Expand Messages
  • Shiva Kumar Mallikarjun
    Hi All, I m trying to remove node from the xml by SimpleXML. as SimpleXML doesnt support removing element So i thoght of doing DOM Interfacing With SimpleXML .
    Message 1 of 1 , Mar 28, 2008
    View Source
    • 0 Attachment
      Hi All,

      I'm trying to remove node from the xml by SimpleXML.

      as SimpleXML doesnt support removing element So i thoght of doing

      DOM Interfacing With SimpleXML .

      So I wrote code , its not working plz help me to solve this problem.

      <?php
      $sxe = simplexml_load_file('1.xml');
      if ($sxe === false) {
      echo 'Error while parsing the document';
      exit;
      }
      $dom_sxe = dom_import_simplexml($sxe);
      if (!$dom_sxe) {
      echo 'Error while converting XML';
      exit;
      }
      $dom_sxe = $dom->importNode($dom_sxe, true);

      while($elem = $dom->getElementsByTagName('note')->item(0)) {
      $dom->removeChild($elem);
      }
      echo '</pre>';
      print_r($dom->saveXML());
      echo '</pre>';

      ?>

      is not working.


      Chat on a cool, new interface. No download required. Go to http://in.messenger.yahoo.com/webmessengerpromo.php

      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.