How to skip invalid characters in XML file using PHP

后端 未结 7 1764
再見小時候
再見小時候 2020-12-01 05:51

I\'m trying to parse an XML file using PHP, but I get an error message:

parser error : Char 0x0 out of allowed range in

I think it\'

7条回答
  •  隐瞒了意图╮
    2020-12-01 06:22

    If you have control over the data, ensure that it is encoded correctly (i.e. is in the encoding that you promised in the xml tag, e.g. if you have:

    
    

    then you'll need to ensure your data is in UTF-8.

    If you don't have control over the data, yell at those who do.

    You can use a tool like xmllint to check which part(s) of the data are not valid.

提交回复
热议问题