免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6452 | 回复: 5
打印 上一主题 下一主题

ASP,PHP给浏览器返回XML [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-03-22 01:50 |只看该作者 |倒序浏览
救急   

当CLIENT使用POST请求TEST.ASP或者TEST.PHP时ASP,PHP直接给浏览器返回一个标准的XML的内容

比如下面的回话过程。PHP或者ASP如何实现

客户端发送的请求数据包:
POST /updates_ent/update.phtml HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel,

application/msword, application/x-shockwave-flash, */*
Content-Type: multipart/form-data; boundary=0a603b9e-312b-4657-a4e6-3e531f361f5d
User-Agent: qq
Host: www.test.com
Content-Length: 933
Connection: Keep-Alive
Pragma: no-cache

--0a603b9e-312b-4657-a4e6-3e531f361f5d
Content-Disposition: form-data; name="XMLFile"; filename="947130ed-cd8b-4a89-809b-3166ca900db0.xml"
Content-Type: text/xml

<?xml version="1.0"?>;
<FilesCatalog>;<MsgVersion>;1</MsgVersion>;<Solutions>;<Solution>;<SolutionID>;3</SolutionID>;<Files>;<File>;<Type>;16</Type>;<DateTime>;

2004-04-16 12:00:00</DateTime>;<NumPatches>;0</NumPatches>;</File>;<File>;<Type>;4</Type>;<DateTime>;2004-07-01

00:00:00</DateTime>;<NumPatches>;0</NumPatches>;</File>;<File>;<Type>;2</Type>;<DateTime>;2004-11-09

10:08:00</DateTime>;<NumPatches>;0</NumPatches>;</File>;<File>;<Type>;8</Type>;<DateTime>;2004-08-16

09:43:09</DateTime>;<NumPatches>;0</NumPatches>;</File>;<File>;<Type>;32</Type>;<DateTime>;2004-07-23

08:44:00</DateTime>;<NumPatches>;0</NumPatches>;</File>;<File>;<Type>;1</Type>;<DateTime>;2004-11-21

08:14:19</DateTime>;<NumPatches>;10</NumPatches>;</File>;</Files>;</Solution>;</Solutions>;</FilesCatalog>;
--0a603b9e-312b-4657-a4e6-3e531f361f5d--

服务器返回的数据包:
HTTP/1.1 200 OK
Date: Mon, 14 Mar 2005 00:04:51 GMT
Server: Apache
X-Powered-By: PHP/4.2.3
Connection: close
Content-Type: text/html

<?xml version="1.0"?>;<FilesCatalog>;<MsgVersion>;1</MsgVersion>;<ServerDateTime>;2005-03-13

19:04:51</ServerDateTime>;<Files>;<File>;<Type>;2</Type>;<DateTime>;2005-03-01

14:00:00</DateTime>;<atches>;</Patches>;<URL>;<CompleteURL>;http://www.test.com/sig.zip</CompleteURL>;</URL>;</File

>;<File>;<Type>;8</Type>;<DateTime>;2005-03-13

10:45:49</DateTime>;<atches>;</Patches>;<URL>;<CompleteURL>;http:///www.test.com/pre.zip</CompleteURL>;</URL>;</File

>;<File>;<Type>;32</Type>;<DateTime>;2005-03-01

11:00:00</DateTime>;<atches>;</Patches>;<URL>;<CompleteURL>;http://www.test.com/dat.zip</CompleteURL>;</URL>;</File>;

<File>;<Type>;1</Type>;<DateTime>;2005-03-14

00:31:57</DateTime>;<atches>;<ackedURL>;http://www.test.com/rche10.zip</PackedURL>;<Names>;<Name>;081111.up</Name>;<Name>;080437.up</Name>;<Name>;220958.up</Name>;<Name>;145625.up</Name>;<

Name>;092948.up</Name>;<Name>;175746.up</Name>;<Name>;112617.up</Name>;<Name>ATCH_

172702.up</Name>;<Name>;082805.up</Name>;<Name>;192259.up</Name>;</Names>;</Patches>;<URL>;

<CompleteURL>;http://www.test.com/av.zip</CompleteURL>;</URL>;</File>;</Files>;</FilesCatalog>;

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
2 [报告]
发表于 2005-03-22 15:29 |只看该作者

ASP,PHP给浏览器返回XML

我猜你是不是在说如果让一段PHP代码显示xml格式的文本信息?
如果是的话,直接 echo

论坛徽章:
0
3 [报告]
发表于 2005-03-22 15:54 |只看该作者

ASP,PHP给浏览器返回XML

可以这么说吧,但ECHO写的时候有些字符不能正常写出来
我的问题就是实现上面的那个会话过程

论坛徽章:
0
4 [报告]
发表于 2005-03-23 13:31 |只看该作者

ASP,PHP给浏览器返回XML


header("Content-type: text/xml; charset=gb2312";
然后
echo 'xml内容';

否则浏览器会默认成html格式处理

论坛徽章:
0
5 [报告]
发表于 2005-03-28 03:32 |只看该作者

ASP,PHP给浏览器返回XML

楼上正解。content-type错误

论坛徽章:
0
6 [报告]
发表于 2005-03-29 17:29 |只看该作者

ASP,PHP给浏览器返回XML

各位兄弟
请注意数据包哦
服务器返回的数据包:
HTTP/1.1 200 OK
Date: Mon, 14 Mar 2005 00:04:51 GMT
Server: Apache
X-Powered-By: PHP/4.2.3
Connection: close
Content-Type: text/html

是text/html
实现上面的回话过程就行
HELP ME
困扰我很久啦
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP