如何解析从PHP作为text/xml发送到服务器的XML? [英] How do I parse XML from PHP that was sent to the server as text/xml?
本文介绍了如何解析从PHP作为text/xml发送到服务器的XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个用jQuery编写的客户端脚本,该脚本正在将text/xml数据发送到服务器,但是由于数据不是查询字符串变量,所以我不知道如何解析请求. jQuery如下所示:
I have a client-side script written in jQuery that is sending text/xml data to the server, but I can't figure out how to parse the request since the data is not a query string variable. The jQuery looks like this:
jQuery.ajax({
url: "test.php",
type: "POST",
processData: false,
contentType: "text/xml",
data: xmlDoc,
success: function( data ) {
alert( data );
}
});
xmlDoc是有效的XML文档.我已经在PHP中进行了所有尝试,但是使用simplexml无法获得任何节点或内容.
The xmlDoc is a valid XML document. I've tried everything in the PHP, but I can't get any of the nodes or content using simplexml.
推荐答案
我认为您需要类似的东西:
I think you want something like:
$xml_text = file_get_contents("php://input");
$xml = simplexml_load_string($xml_text);
这篇关于如何解析从PHP作为text/xml发送到服务器的XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文