用JSTL解析XML
我试图从循环中只获取第一条记录,或者如何在第一条记录之后停止此循环用JSTL解析XML,xml,parsing,xml-parsing,jstl,Xml,Parsing,Xml Parsing,Jstl,我试图从循环中只获取第一条记录,或者如何在第一条记录之后停止此循环 <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=
<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>
您可以使用:
<xsl:for-each select="(//*[local-name()='item'])[position() <= 1]">
def result = records.children().find {
domain -> domain.@domain_name == targetDomain
}
result.children().each {
// do stuff
}