0
我有一些XML需要被处理成一个字符串来呈现一些指令。文本看起来像这样我可以只使用e4x还是我也需要regex?
<?xml version="1.0" encoding="UTF-8"?>
<instructions id="detection" version="1.0">
<instruction task="detection">
<phrase type="header">HAS THE CARD TURNED OVER?<nl/><nl/><nl/></phrase>
<phrase type="practice">you are now going to do a practice.<nl/><nl/></phrase>
<phrase type="real">You are now going to do a test.<nl/><nl/></phrase>
<phrase>As soon as the card turns face up:<nl/><nl/></phrase>
<phrase><ts/><ts/>Press YES.<nl/><nl/></phrase>
<phrase>Go as fast as you can and try not to make any mistakes.<nl/><nl/></phrase>
<phrase>If you press YES before a card turns face up, you will hear an error sound.</phrase>
</instruction>
</instructions>
现在,所有我需要做的是以下
- 替换所有
<nl/>
与\ n - 替换所有
<ts/>
与\ t - 有条件选择的做法或真正的,可能是通过删除其他
- 删除所有剩余的XML位以产生一个字符串。
所以可以说,我想这个做法的版本,我应该
HAS THE CARD TURNED OVER?\n\n\n
you are now going to do a practice.\n\n
As soon as the card turns face up:\n\n
\t\tPress YES.\n\n
Go as fast as you can and try not to make any mistakes.\n\n
If you press YES before a card turns face up, you will hear an error sound.
落得现在,我必须改变XML结构的机会,如果目前的形式并不理想为此,但我不确定的是,如果我可以使用e4X完成上述所有操作,或者我还需要使用正则表达式的?一些例子会很棒。
进行类型。你实际上需要“\ n”,还是会出现一个视觉上的突破,比如你使用
标签的工作? – 2012-07-25 02:50:33
它进入一个textarea,它目前使用\ n \ t硬编码文本,我们将它移动到一个xml配置系统 – 2012-07-25 02:59:31
我会使用
而不是试图用\ n替换。我想你可以在需要标签的地方使用标签。此时,您只需在包含您的实际值或练习值的XMLList上调用toString()。如果您未在TextArea上设置condenseWhite,则可能甚至不需要
标记,但可以通过将回车位置放在需要的位置来格式化文本。 – 2012-07-25 03:16:29