I have a xml file for example,
<title> hello <name> hi </name> <street> id </street> this is xml file </title>
Here the parent node is title
. I am going to extract the text inside the parent node removing the inner tags.
I have tried with the regex. But Is there any way other than using regex like, using some xml based functions to remove the tags. Note: the tag name is not known beforehand.
Hi I have tried this, I used the same xml
use XML::Simple; use Data::Dumper; my $simple = XML::Simple->new(); my $data = $simple->XMLin('XMLRemoval.xml'); my %oldHash = %$data; my %newHash = (); while ( my ($key, $innerRef) = each %oldHash ) { $newHash{$key} = @$innerRef[1]; } foreach $key ( keys %newHash ) { print $newHash{$key}; }
And I am getting the error : Can't use string (" id ") as an ARRAY ref while "strict refs"