如何将 dtd 验证添加到 `xml.etree.cElementTree.iterparse`
我知道,这种在解析 xml 文件之前进行 dtd 验证的方法是有效的:
from lxml import etree
context = etree.iterparse(PATH_TO_XML, dtd_validation=True, events=("start", "end"))
但是如何让它适用于 xml.etree.cElementTree.iterparse?
from xml.etree.cElementTree import iterparse
context = iterparse(PATH_TO_XML, ???, events=("start", "end"))
I know, that this way of dtd validation before parsing a xml file works:
from lxml import etree
context = etree.iterparse(PATH_TO_XML, dtd_validation=True, events=("start", "end"))
But how do I get this to work for the xml.etree.cElementTree.iterparse
?
from xml.etree.cElementTree import iterparse
context = iterparse(PATH_TO_XML, ???, events=("start", "end"))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
cElementTree 不是 lxml 的一部分。
根据 cElementTree 网站,DTD 验证不适用于 cElementTree。
cElementTree is not part of lxml.
According to the cElementTree website, DTD Validation is not available to cElementTree.