Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Replace the Text of an XML Element Using LibXML and DOM

by lestrrat (Deacon)
on Jul 01, 2002 at 23:09 UTC ( #178728=note: print w/replies, xml ) Need Help??


in reply to Replace the Text of an XML Element Using LibXML and DOM

How about:

foreach my $node ( $dom->findnodes( '/Message/Body' ) ) { my $decoded = decode_base64($node->textContent()); $node->removeChild( $node->firstChild() ); $node->appendTextNode( $decoded ); }

Replies are listed 'Best First'.
Re: Re: Replace the Text of an XML Element Using LibXML and DOM
by jmurphy (Acolyte) on Jul 02, 2002 at 18:40 UTC
    Thanks so much for the reply,

    Hopefully this can help someone else. I ended up implementing as follows:

    my $root = $dom->getDocumentElement; my $bodies = $root->getElementsByTagName( "MessageBody" ); foreach my $body ( $bodies->get_nodelist() ) { my $encoded_node = $body->firstChild(); $encoded_node->replaceDataString( $encoded_node->data(), decode_ba +se64( $encoded_node->data() )); }
    Again thanks. You got me going on the right path.

    Take care,
    Jay

      I learned something new, too :) ( didn't know about replaceDataString() )

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://178728]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2023-02-07 08:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (38 votes). Check out past polls.

    Notices?