python-lxml/plans/etree-fromstring.py

8 lines
170 B
Python
Raw Permalink Normal View History

2022-08-31 05:03:13 +00:00
import lxml.etree as et
s = '<foo><bar baz="xyzzy">a<![CDATA[b]]>c</bar></foo>'
x = et.fromstring(s)
t = x.find('bar').text
print(t)
if t != 'abc':
raise Exception()