PHP - SimpleXML parse error

前端 未结 4 999
小鲜肉
小鲜肉 2020-12-10 07:21

SEE EDITS AT BOTTOM TO SHOW MORE ACCURATE ERROR OUTPUT

I\'m parsing somewhat large (~15MB) XML files with PHP for the first time using SimpleXML. The files are flig

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-10 07:54

    Darryl has the right answer as to why this is happening in his comment above. One way of fixing this would be to do a str_replace() to replace all '&' ampersands with '&' in the XML. According to the PHP manual you could also use this regular expression to replace ampersands with their entities:

    $s = preg_replace('/&[^; ]{0,6}.?/e', "((substr('\\0',-1) == ';') ? '\\0' : '&'.substr('\\0',1))", 
    

提交回复
热议问题