dongyi1982 2012-05-26 12:15 采纳率: 0%
浏览 24
已采纳

如何在php中回显xml?

I have this function and I need to echo an XML but it doesnt work. what is the problem?

static function login_xml($ERROR_ID,$SESSION_ID)
{
  echo "<BR>IN LOGINXML<BR>"; 


  echo '<xml version="1.0">'.
  '<response>log_in</response><parameters><error>'.$ERROR_ID.'</error><session>'
  .$SESSION_ID.'</session></parameters></xml>';
 }

I tried with header('Content-type: text/xml'); before echo, that doesnt work either. What can I do?

  • 写回答

1条回答 默认 最新

  • douseda0009 2012-05-26 12:17
    关注

    Simply remove the line

    echo "<BR>IN LOGINXML<BR>"; 
    

    XML should have only one root element, that is <xml> in your case

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

报告相同问题?