Posted on 2007-06-23 22:37:30-07 by dbmathis in response to 5515
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; }
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.