xml-获取特定节点的前160个字符

xml-获取特定节点的前160个字符,xml,coldfusion,Xml,Coldfusion,我们将这个xml(针对这个问题进行了缩短和简化)返回到我们的coldfusion应用程序,在那里它被解析出来并用于新闻滚动: <newsItems> <newsItem content="The International Rugby Board (IRB) has confirmed that it will take a hardline stance on any team that breaks certain parameters when an nation

我们将这个xml(针对这个问题进行了缩短和简化)返回到我们的coldfusion应用程序,在那里它被解析出来并用于新闻滚动:

<newsItems>
   <newsItem content="The International Rugby Board (IRB) has confirmed that it will take a hardline stance on any team that breaks certain parameters when an nation performs a traditional haka. This will not only apply to the All Blacks haka, but the various challenges performed by the Pacific Island teams as well for moving too close to the Black Ferns while they performed their haka. The Australian Rugby Union (ARU) paid the fine, after it was revealed by a Sydney newspaper that there was a clause in the IRB tournament rules that dictated that teams must face the haka, and remain 10 metres on their own side of the halfway line. For the record the Black Ferns won that pool match 32-5. Senior IRB officials confirmed that the regulation was in place - and had been for some time - but the fine imposed on the ARU was the first time that formal action had been taken."  extension="jpg" fileName="261840D4-CADD-6C4E-ACAF532ACFF12388" link="news/14266/IRB-confirms-haka-will-not-be-challenged" title="IRB confirms haka will not be challenged....."/>

</newsitems>

然而,最初我们只想返回内容的前160个字符。我们不希望将几千个字符拖到应用程序中,然后只解析出前160个字符。我们只需要在应用程序中输入前160个字符的XML,然后使用该XML

最简单的方法是什么

提前感谢,, Paul

考虑到需要将内容缩减到160个字符,让ColdFusion这样做可能很有意义,因为这确实是一个演示问题。您的底层服务(DB、Web服务调用,等等)可以有一个更简单的API,它返回所有内容,您在CF中的表示代码可以根据需要进行精简

同样值得考虑的是,如果只获取内容的前160个字符,那么获取XML是否真的会更加高效。如果您是通过网络获取数据,那么额外的内容可能会全部放入与修剪版本相同数量的数据包中。 您可以运行来测量两种方法之间的差异,看看效果如何


如果您可以发布更多关于数据来源的详细信息,那将非常有帮助。

您没有提到XML的来源。如果您希望避免获取超过160个字符,那么您可能必须在保存XML的任何位置执行此操作。