Hi ,

Below is my requirement

I have an XML like

<sys xmlns="urn:mavenir:ns:yang:wrg-sc:6.0.2.8"> <platform><contact> <name>Mavenir</name> <phone>214-616-3499</phone> </contact> <solution> <name>mOne</name> <fkcontact>Mavenir</fkcontact> </solution> <tmmTableFilenameMap> <fileName>ALARM</fileName> <tableId>1</tableId> </tmmTableFilenameMap> <tmmTableFilenameMap> <fileName>AVGOVLDPERF</fileName> <tableId>7</tableId> </tmmTableFilenameMap> </platform> </sys>

I want to delete all nodes with tmmTableFilenameMap

I tried the below code

#!/usr/bin/perl use 5.010; use strict; use warnings; use XML::LibXML; my $filename = 'webrtcc_system_static_config_data_platremoved.xml'; my $a; my $dom = XML::LibXML->load_xml(location => $filename); my $book = $dom->documentElement; my $del="tmmTableFilenameMap"; my @a = $book->findnodes("tmmTableFilenameMap"); $book->removeChild($a); print $book->serialize();

It gives a strange error as below

XML::LibXML::Node::removeChild() -- node is not a blessed SV reference + at DeleteNodesXml.pl line 17.

Could some one help on this

2019-04-26 Athanasius added code and paragraph tags


In reply to LibXML error when trying to delete a node in DOM by msivask

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.