【问题标题】:Parse XML with JSTL使用 JSTL 解析 XML
【发布时间】:2012-09-16 17:00:25
【问题描述】:

我试图只从循环中获取第一条记录,或者如何在第一条记录后停止此循环?

<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>

【问题讨论】:

    标签: xml parsing xml-parsing jstl


    【解决方案1】:

    你可以使用:

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

    或:

    def result = records.children().find {
        domain -> domain.@domain_name == targetDomain
    }
    
    result.children().each {
        // do stuff
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-03
      • 2011-04-22
      • 2014-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多