当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python xml.dom.pulldom.DOMEventStream.expandNode用法及代码示例


用法:

expandNode(node)

node 的所有子级扩展为 node 。例子:

from xml.dom import pulldom

xml = '<html><title>Foo</title> <p>Some text <div>and more</div></p> </html>'
doc = pulldom.parseString(xml)
for event, node in doc:
    if event == pulldom.START_ELEMENT and node.tagName == 'p':
        # Following statement only prints '<p/>'
        print(node.toxml())
        doc.expandNode(node)
        # Following statement prints node with all its children '<p>Some text <div>and more</div></p>'
        print(node.toxml())

相关用法


注:本文由纯净天空筛选整理自python.org大神的英文原创作品 xml.dom.pulldom.DOMEventStream.expandNode。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。