2011-08-04 32 views
0

我们有这个XML(缩短和简化了这个问题)的第160个字符,回到我们的ColdFusion的应用程序,它被解析出来,用于在新闻辊:XML - 获取特定节点

<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个字符。我们需要将XML仅带入前160个字符,然后使用该XML。

最简单的方法是什么?

由于提前, 保罗

+0

你没有提到XML来自哪里。如果您希望避免使用超过160个字符,那么您可能必须在XML的任何位置执行此操作。 – barnyr

回答

0

鉴于东西将不得不削减的内容,以160个字符,它很可能是有意义的有ColdFusion的做到这一点,因为它是一个真正的呈现问题。你的底层服务(DB,Web服务调用,无论什么)都可以有一个更简单的API,它可以返回所有的内容,并且你的演示代码可以修改为适合。

同样值得考虑的是,仅通过获取内容的前160个字符来获取XML是否真的会更有效。如果你通过网络获取数据,额外的内容可能都适合与修剪版本相同数量的数据包。 您可以运行WireShark来衡量方法之间的差异以查看效果是什么。

如果您可以发布更多关于数据来自何处的详细信息,那将有很大帮助。