简体   繁体   English

在json之前转义文本字符串

[英]escaping a text string before json

Im converting a XML document to JSON from PHP backend and returning it to frontend using ajax like so: 我将XML文档从PHP后端转换为JSON并使用ajax将其返回到前端,如下所示:

print_r(json_encode($result_xml)); print_r(json_encode($ result_xml));

The response can be seen here: https://api.myjson.com/bins/6ndc7 可以在这里看到响应: https : //api.myjson.com/bins/6ndc7

the problem is that $result_xml also contains some text right before that response which is the following: 问题是$ result_xml在该响应之前还包含一些文本,如下所示:

URL: http://sandbox.cargonizer.no/transport_agreements.xml <'br> Took 2.178947 seconds to send a request to http://sandbox.cargonizer.no/transport_agreements.xml <'br> URL: http ://sandbox.cargonizer.no/transport_agreements.xml <'br>花费2.178947秒将请求发送到http://sandbox.cargonizer.no/transport_agreements.xml <'br>

(without the single-quote in <'br>) (在<'br>中没有单引号)

So my question is: How can I ignore the first two lines of string? 所以我的问题是:如何忽略字符串的前两行?

拆分$ result_xml变量,然后仅发送xml进行解析。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM