This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center




已关闭8年。




我有一个解析一些XML(adf)内容的脚本。有时我们会收到损坏的XML数据(即语法,无结束标记等)。
SimpleXMLElement引发错误并杀死我的脚本,如何分配类似$xml_body = new SimpleXMLElement ($adf_xml);的内容并捕获解析异常?

最佳答案

好的,因此显然捕获XML Parse错误有点像是 chalice ……我最终只是

try { $x = new SimpleXMLElement($y, LIBXML_NOERROR); } catch (Exception $e) { echo $e; }

编辑:感谢@PanPipes

关于xml - PHP捕获SimpleXMLElement解析错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4137645/

10-10 19:42