简体   繁体   English

从xml.dom导入DOMImplementation,DocumentType

[英]from xml.dom import DOMImplementation, DocumentType

I'm trying to get a Python script working, that is using xml.dom (not xml.dom.minidom). 我正在尝试使用xml.dom(而不是xml.dom.minidom)来运行Python脚本。

I'm working on a new install of Python 2.7 for Windows, and xml.dom doesn't have a DOMImplementation or a DocumentType. 我正在为Windows安装新的Python 2.7,并且xml.dom没有DOMImplementation或DocumentType。

Is there some additional module I need to install? 我是否需要安装一些其他模块?

xml.dom only provides DOM interfaces, it is not a DOM implementation. xml.dom仅提供DOM接口,而不是 DOM实现。

Only xml.dom.minidom provides an implementation; 只有xml.dom.minidom提供了一个实现。 xml.dom.pulldom provides a on-demand tree builder. xml.dom.pulldom提供了按需的树生成器。

Note that the ElementTree API offers a far more Pythonic API to process XML documents; 请注意, ElementTree API提供了更多的Pythonic API来处理XML文档。 unless you are married to the DOM API, you'll find the ElementTree API to be easier to use for most use cases. 除非您已嫁接到DOM API,否则您会发现ElementTree API在大多数情况下都更易于使用。

Sorry to bother everybody. 很抱歉打扰大家。

On further examination, it turns out that the code I was trying to get working simply doesn't work. 经过进一步检查,结果发现我试图使之正常工作的代码不起作用。 In essence, it was an attempt to write a SOAP client using Python's xml.dom and httplib modules - and it was simply done wrong. 从本质上讲,这是尝试使用Python的xml.dom和httplib模块编写SOAP客户端的尝试-这样做完全是错误的。

I'm scrapping his code, and writing a proper SOAP client. 我正在废弃他的代码,并编写适当的SOAP客户端。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM