in reply to
Finding max value from a unique tag from XML
A single XPath expression can find a maximum. Here is an example using XML::XSH2, a wrapper around XML::LibXML:
open 1.xml ;
echo //doc/str[@name="docuid" and not(text() < //doc/str[@name="docuid
That's more XPath wizardry than I'd normally manage. FWIW, here's the translation of the above to plain old XML::LibXML:
use XML::LibXML 1.70;
my $xml = XML::LibXML->load_xml(location => "1.xml");
//doc/str[@name="docuid" and not(text() < //doc/str[@name="docuid"
By rote learning.
Via Genetic memory.
It's provided by my firmware.
I just remember them.
Thirty days hath September
My computer gets it right, usually.
I just ask someone else.
Someone punches me on the first of the month.
Results (246 votes),