duanju8431 2011-06-15 16:54
浏览 180

从CURL解析XML响应 - 很困惑

Using CURL, I send an xml file to a server and receive a 200 response and reciprocal XML file from said server.

$response = curl_exec($session);

So far so good. If I do print_r($response) I see that the url i need is indeed inside $response.

The question i have is how do i parse it out? I try variations of the following but nothing seems to work:

$xml = new SimpleXMLElement($response);

Pointer in the right direction would be great.

Thanks!

  • 写回答

2条回答 默认 最新

  • douxi0098 2011-06-15 17:02
    关注

    You need use the following structure:

    
    
    
    $xml = new SimpleXMLElement($response);
    echo $xml->movie[0]->plot;
    
    //Or
    $xml = simplexml_load_file($file, 'SimpleXMLElement', LIBXML_NOCDATA);
    

    Where movie is a node from yor xml structure.

    评论

报告相同问题?

悬赏问题

  • ¥15 outlook无法配置成功
  • ¥15 Pwm双极模式H桥驱动控制电机
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换