#!/usr/bin/perl package MyHandler; use strict; use warnings; use base qw(XML::SAX::Base); use Data::Dumper; sub start_element { my $self = shift; my $data = shift; if( $data->{LocalName} eq 'span') { $data->{LocalName} = 'naps'; } $self->SUPER::start_element($data); # GOOD (and easy) ! #print Dumper($data); } 1; #============================ #Main programm #============================ use strict; use warnings; use XML::SAX::ParserFactory; use XML::SAX::Writer; my $out; my $o = XML::SAX::Writer->new( Output => \$out ); my $h = MyHandler->new( Handler => $o ); my $p = XML::SAX::ParserFactory->parser(Handler => $h); my $data; { local undef $/ }; $data = ; $p->parse_string( $data ); print $out; __DATA__
Edit Information: Name: Last Name: DOB: Occupation: Gender:
#### #### This is an expanded element