Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

How to remove empty XML elements using XML::LibXML

by FreakyGreenLeaky (Sexton)
on Feb 17, 2013 at 19:22 UTC ( #1019196=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    <?xml version="1.0" encoding="UTF-8"?>
    <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.o
    +rg/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:n
    +s:epp-1.0 epp-1.0.xsd">
    ...
            <contact:id>testaccount3</contact:id>
            <contact:add/>
            <contact:rem/>
    
  2. or download this
    for my $remove ($frame->findnodes(q{/command/update/contact:update/con
    +tact:add})) {
        $remove->unbindNode;
    }
    
  3. or download this
    XPath error : Undefined namespace prefix
     error : xmlXPathCompiledEval: evaluation failed
    
  4. or download this
    sub new {
        my $package = shift;
    ...
    
        return $self;
    }
    
  5. or download this
    my $p = $frame->getElementsByTagName('contact:update');
        foreach my $n ($p->[0]->childNodes()) {
            $p->[0]->removeChild($n) if $n->toString(1) eq "<contact:add/>
    +";
        }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1019196]
Front-paged by Corion
help
Chatterbox?
[Eily]: is the Bishop of hearts higher or lower ranked than the Jack?
[ambrus]: Higher.
[Eily]: Discipulus what's the merchandise? Other bi-people?
[1nickt]: marto would like to hear that. Of course he speaks very deliberately and dramatically, allowing pauses between words, so if anybody could pull it off it would be him, or someone impersonating him ...
[Eily]: Discipulus that's a chess joke BTW right? Because bishops don't walk straight :D
[choroba]: stop making chessy jokes about bishops!
[choroba]: I mean cheesy
[LanX]: lol
[ambrus]: no, the chess bishop itself is a joke on real bi-shops
[ambrus]: or at least on the stereotype of bi-shops

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (15)
As of 2017-09-26 12:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (294 votes). Check out past polls.

    Notices?