douye1940 2012-09-17 21:40
浏览 32
已采纳

如何从PHP输出XML并让它显示“很好”?

I'm using php's SOAPClient class to make SOAP requests and to get SOAP responses, but I need to display the request and response xml on the page for debugging purposes. Problem is, I can't figure out how.

I can use the __getLastRequest() and __getLastResponse() methods to get the xml strings, but I have not found a way to print them out nicely. I did discover that echo'ing out <xmp>[xmlstringhere]</xmp> puts the appropriate xml tags in the string, but there aren't any line breaks, which is a problem since the xml response is HUGE. If only I could get line breaks in the appropriate places, and proper indenting, things would be golden.

Up until now I've been having to copy the outputted xml, save it as a .xml file, and open that. Is there a way to output things in a readable format via php?

  • 写回答

1条回答 默认 最新

  • dougou8552 2012-09-17 21:42
    关注

    Try echo '<pre>' . $client->__getLastRequest() . '</pre>';

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿