我对 FTL 相当陌生,并且遇到了一个问题。我必须从 FTL 代码中读取 XML,然后遍历它以显示数据。问题是互联网上没有太多可用于 FTL 的文档,我无法得出如何实现这一点的结论。以下是我编写的示例代码,请让我知道我做错了什么。
文件
<response status="success">
<threads>
<thread type="thread" href="/threads/id/4999">
<id type="int">4999</id>
<subject type="string">
Testing of the XML and FTL 1
</subject>
<message_rating type="float">0.0</message_rating>
<thread type="thread" href="/threads/id/4999"/>
<last_edit_time type="date_time">2013-10-01T14:08:04+00:00</last_edit_time>
<last_edit_author type="user" href="/users/id/149">
</last_edit_author>
<labels/>
<board type="board" href="/boards/id/10031"/>
<views>
<count type="int">1</count>
</views>
</linear>
<read>
<count type="int">1</count>
</read>
<count type="int">1</count>
</thread>
<thread type="thread" href="/threads/id/4999">
<id type="int">4998</id>
<subject type="string">
Testing of the XML and FTL 2
</subject>
<message_rating type="float">1.0</message_rating>
<thread type="thread" href="/threads/id/4999"/>
<last_edit_time type="date_time">2013-10-02T14:08:04+00:00</last_edit_time>
<last_edit_author type="user" href="/users/id/149">
</last_edit_author>
<labels/>
<board type="board" href="/boards/id/10031"/>
<views>
<count type="int">2</count>
</views>
</linear>
<read>
<count type="int">1</count>
</read>
<count type="int">1</count>
</thread>
.
.
.
.
.
.
.
.
.
</threads>
</response>
我正在进行一个返回上述 XML 的 REST 调用,下面是我编写的 FTL 代码。
通过 FTL 响应,我需要获取主题、观看次数和董事会 URL。
<#assign active_board = restadmin("/boards/id/10031/threads")>
<!-- I AM NOT SURE HOW TO ITERATE THORUGH THE XML AND GET THE LIST OF ABOVE MENTIONED THINGS I NEED AND DISPLAY IT ON FRONT END -->
<#assign message_list = restadmin("/threads/id/4999").thread.messages> <!--THIS IS ANOTHER REST CALL-->
<#assign count = message_list.topic.kudos.count?number>
<#list message_list.linear.message as m>
<# count = count+m.kudos.count>
</#list>