美文网首页
写python遇到的坑

写python遇到的坑

作者: 予早 | 来源:发表于2019-01-21 17:50 被阅读0次

xml含有非法字符

This page contains the following errors: error on line 16 at column 274505: PCDATA invalid Char value 27 Below is a rendering of the page up to the first error.

php、ruby: https://stackoverflow.com/questions/12229572/php-generated-xml-shows-invalid-char-value-27-message

function utf8_for_xml($string)
{
    return preg_replace ('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', ' ', $string);
}

python: https://github.com/tanium/pytan/blob/master/lib/pytan/xml_clean.py

相关文章

网友评论

      本文标题:写python遇到的坑

      本文链接:https://www.haomeiwen.com/subject/dfqhjqtx.html