where a tag (<str name="docuid">) appears multiple times. i need to fetch data from all the docid tags and find max value from that. I used following code::<doc> <date name="processingtime">2011-04-09T11:12:22.049Z</date> <str name="docuid">121422</str> <str name="title">ABC</str> <\doc> <doc> <date name="processingtime">2012-04-09T11:12:22.049Z</date> <str name="docuid">13427</str> <str name="title">CDE</str> <\doc> <date name="processingtime">2010-04-09T11:12:22.049Z</date> <str name="docuid">89822</str> <str name="title">LKK</str> <\doc>
This code is solving my purpose, but is there any better way to achieve this.$html =~ s/<doc>/<doc>\n\n\n\n\n\n/g; my (@lines) = split("\n\n\n\n\n", $html); $cn = scalar(@lines); for($i = 0; $i<$cn; $i++) { if ($lines[$i] =~ m/<str name="docuid">(.*?)<\/str>/) { $docuid[$i] = $1; } } my $max = max @docuid;
In reply to Finding max value from a unique tag from XML by Shaveta_Chawla
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |