Order Xml item by date from XPath query

ledgerlady

New Member
I'm writing some perl scripts that reads from an Xml file through XPath query.From Perl scripts, I need to return the 3 movies with the most recent date ( similar to order film by date ).xml file:\[code\]<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="http://stackoverflow.com/questions/10796052/films.xsl"?><collection xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://...." xs:schemaLocation="http://.. films.xsd"><film id="1"> <title>Title1</title> <date>2011-09-24</date> <family>Action</family></film><film id="4"> <title>Title2</title> <date>1980-09-24</date> <family>Thriller</family></film></collection>\[/code\]How can I do?? I read and try more solutions but anything.I try\[code\]my $nodeset = $xp->findnodes("/collection/film[not(\@id < preceding-sibling::collection/film[\@id] ) and not(\@id < following-sibling::collection/film[\@id])]" );\[/code\]i try the max function of XPath 2.0 only to return the most recent,i try xsl\[code\]<xsl:for-each select="collection/film/date"><xsl:sort select="." data-type="date" order="descending"/><xsl:value-of select="title"/></xsl:for-each>\[/code\]
 
Back
Top