$xmlStr = "
<eweb>
 <bank>
  <response>
   <result>
    <command-type>FINISH_ONLINE_RECHARGE_ORDER</command-type>
    <code>10000</code>
    <message>Command Successful!</message>
    <time>2010-01-01 18:00:01</time>
   </result>
   <data>
    <money>充值成功的金额(必选)</money>
   </data>
  </response>
 </bank>
</eweb>";
这样就可以解析,但是如果
$xmlStr = "
<?xml version=\"1.0\" encoding=\"gbk\"?>
<eweb>
 <bank>
  <response>
   <result>
    <command-type>FINISH_ONLINE_RECHARGE_ORDER</command-type>
    <code>10000</code>
    <message>Command Successful!</message>
    <time>2010-01-01 18:00:01</time>
   </result>
   <data>
    <money>充值成功的金额(必选)</money>
   </data>
  </response>
 </bank>
</eweb>";
就不能解析,为什么呢?
另外如果我自己创建了一个标准格式的xml字符串
用浏览器输出如下,
  <?xml version="1.0" encoding="gb2312" ?> 
- <eweb>
- <bank>
- <login>
  <card-id>111</card-id> 
  <card-password>888</card-password> 
  </login>
- <command type="CASH_PAYMENT">
  <money>778899</money> 
  <description>778943136</description> 
  <other-side-account-id>1111</other-side-account-id> 
  <terminal-type>a</terminal-type> 
  <terminal-code>b</terminal-code> 
  </command>
  </bank>
  </eweb>
也是可以解析的,请问怎么会这样呢?请高手帮我啊!!

解决方案 »

  1.   

    $xmlStr = "
    <?xml version='1.0' encoding='gbk'?>
    <eweb>
     <bank>
      <response>
      <result>
      <command-type>FINISH_ONLINE_RECHARGE_ORDER</command-type>
      <code>10000</code>
      <message>Command Successful!</message>
      <time>2010-01-01 18:00:01</time>
      </result>
      <data>
      <money>充值成功的金额(必选)</money>
      </data>
      </response>
     </bank>
    </eweb>";
      

  2.   


    谢谢啊!又帮我了一次,你真是太猛了,顺便帮我看看另一个问题吧
    http://topic.csdn.net/u/20100713/15/dc40957e-62ea-4a86-8ed1-2b3b7c9a143e.html?29062