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 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探