首页 > 用Python如何获取XML中的CDATA数据?

用Python如何获取XML中的CDATA数据?

例,这里的数据如何得到?

<![CDATA[ apache配置flask出现错误 ]]>

如果 @woahoooo 的方法不想用,那就用正则吧:

#! /usr/bin/env python
#-*- coding: UTF-8 -*-

import re

s = u"<![CDATA[ apache配置flask出现错误 ]]>";

rgx = re.compile("\<\!\[CDATA\[(.*?)\]\]\>")
m = rgx.search(s)
print m.group(1)

http://stackoverflow.com/questions/59...
this may help u

【热门文章】
【热门文章】