如何在 ActionScript 中对保留的 XML 字符进行编码?
我正在 Flex 中编写一个业务应用程序,它使用 Web 服务与中间层进行通信。 Web 服务接受并返回 XML 格式的消息。在许多情况下,我需要能够允许用户在应用程序的字段中输入类似以下内容,该字段又将作为元素添加到绑定到 SOAP Web 服务的 XML 有效负载中(不带引号) :
“帐户余额 < 1000”
当尝试在文本节点中序列化一个元素时,Flex 解析器会阻塞(例如,帐户余额 < 1000)。所以我需要某种方法将“<”编码为“<”在进行 XML 序列化之前,我更喜欢使用通用方法来执行此操作,例如在服务声明中使用属性,因为我有 40 多个服务必须支持此类输入。
I am writing a business app in Flex that uses web services to communicate with a middle tier. The web services accept and return messages in XML format. In many cases, I need to be able to allow the user to type something like the following into a field in the app, which in turn will be added as an element in an XML payload bound for a SOAP web service (without the quotes):
"account balance < 1000"
The Flex parser chokes when trying to serialize an element with this in the Text node (e.g., account balance < 1000. So I need some way to encode the "<" to "<" prior to doing the XML serialization. In addition, I would prefer a generic way to do this, such as with an attribute on the service declaration, since I have over 40 services that must support this kind of input. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 escape 和 unescape 函数。
http://www.adobe.com/support/flash/action_scripts/ actionscript_dictionary/actionscript_dictionary199.html
use the escape and unescape functions.
http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary199.html