I need to parse an XML file without using module.
In that XML file I need to extract all content between 2 tags (<mi>
...</mi>
) that match a pattern.
I have this:
$xmlstring = my xml string
$pattern = "G2_CPU";
my $regex = "<mi>(.*?" . $pattern . ".*?)<\\/mi>";
my ($data) = $xmlstring =~ /$regex/i;
But when I execute it, in $data
I got everything between the very first <mi>
tag and the very last </mi>
tag.
I also try with the regex without variable: /(<mi>.*?G2_CPU.*?<\/mi>)/
and I got the same result.
How can I do it?