CDATA 中的和号 (&) 破坏了 XML POST 请求
我正在发送带有“&”的 xml 请求在 CDATA 中,
<![CDATA[red & blue]]>
它通过结束 &
所在位置来破坏我的 XML。有什么想法如何避免这种情况吗?我也尝试过 &
,但它仍然在同一位置中断。
这是使用curl请求和输出结果的链接
服务器正在运行 codeigniter
I am sending an xml request with a '&' in CDATA
<![CDATA[red & blue]]>
Its breaking my XML by ending where the &
is. Any ideas how to avoid this? I have tried &
also and it still breaks at the same location.
Here is link to request and output of results using curl
The Server is running codeigniter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你所说的“打破”是什么意思?您需要更具体地说明您正在做什么以及出了什么问题。
如果您使用 SAX 解析器,请注意,SAX 可以将文本节点分解为多个片段,并一次交付一个片段。它可以在任何地方中断节点,但 SAX 解析器在对解析器很重要的字符处中断节点的情况并不少见,例如“&”。
我现在已经查看了您的 Pastebin 消息(很难阅读白底黄字......)。我不熟悉你使用的工具,但它们似乎严重损坏。它实际上无法识别 CDATA 部分,而是将其序列化为
"<![CDATA["
,这显然是错误的。如果它无法识别 CDATA,那么它可能会将 & 符号视为启动实体引用,因此在此之后,所有的赌注都会被取消。What do you mean by "breaking"? You need to be more specific about what you are doing and what is going wrong.
If you are using a SAX parser, note that SAX can break text nodes up into pieces and deliver the pieces one at a time. It can break the nodes anywhere, but it's not uncommon for SAX parsers to break them at characters that are significant to the parser, such as '&'.
I've now looked at your pastebin message (hard to read yellow on white...). I'm not familiar with the tools you are using but they seem badly broken. It's actually not recognizing the CDATA section, it's serializing it as
"<![CDATA["
which is clearly wrong. If it's not recognizing the CDATA then it's probably going to treat the ampersand as starting an entity reference, so after that, all bets are off.