2012-09-16 44 views
0

我想從循環中獲取第一條記錄,或者如何在第一條記錄後停止循環?用JSTL解析XML

<x:parse var="taggedData" xml="${taggedLoad}"/> 
<x:forEach var="item" select="$taggedData//item" varStatus="status"> 
    <h4> 
     <a href="/go/video/index.jsp?videoId=<str:substring start="5"><x:out select="$item/guid"/></str:substring>" onclick="javascript:loadBCvideo(<str:substring start="5"><x:out select="$item/guid"/></str:substring>); return false;"><x:out select="$item/title" /></a> 
    </h4> 
    <p> 
     <x:out select="$item/description" escapeXml="false" /> 
    </p> 

回答

0

你可以使用:

<xsl:for-each select="(//*[local-name()='item'])[position() &lt;= 1]"> 

或:

def result = records.children().find { 
    domain -> [email protected]_name == targetDomain 
} 

result.children().each { 
    // do stuff 
}