dsz1966 2016-04-08 17:23
浏览 84

奇怪的xml特殊字符,无法使用curl和SimpleXMLElement进行解析

I'm downloading an xml file using curl and then parsing it using simplexml_load_string() and putting it to db.

I got a problem a that the file cannot be parse, its inside <![CDATA[]]> and i notice the file has some sort of a special character that i really dont know:

special character

I'm getting the file like so:

$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c);
curl_close($c);

and i'm parsing it like so:

$gpx = simplexml_load_string($myfile,'SimpleXMLElement', LIBXML_NOCDATA);

The error that I got is this:

simplexml_load_string(): Entity: line 7238: parser error : CData section not finished

How can i disregard those in to properly parse the xml file?

Thanks so much in advance.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 有没有可以帮我搞一个微信建群链接,包括群名称和群资料群头像那种,不会让你白忙
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题