XML-Twig - Re: Modify a compex XML documaent with XML::Twig

Posted on Sun Jun 24 01:37:30 2007 by dbmathis in response to 5515 (See the whole thread of 4)
Re: Modify a compex XML documaent with XML::Twig
This seems to do what I am looking for.. Thank you so much for your help mirod.

#!/usr/bin/perl -w use strict; use warnings; use XML::Twig; XML::Twig->new( twig_roots => { Comments => \&comments }, twig_print_outside_roots => 1, keep_spaces => 1, ) ->parsefile( 'resume.xml'); exit; sub comments { my( $t, $comments) = @_; if( $comments->field( 'Prompt')=~ m{Briefly describe your qualifications for this position}) { my $response= $comments->first_child( 'Response'); if( $response) { my $trncd = substr($response->text, 0, 1000); $response->set_cdata( $trncd); } } $t->flush; }
Write a response