写python遇到的坑

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

猜你喜欢

转载自blog.csdn.net/weixin_34148508/article/details/87504611