コンテンツにスキップ

未翻訳のページ

このページはまだ日本語に翻訳されていないため、英語の原文を表示しています。 翻訳に協力する

xml.dom Module

The xml.dom module defines the Document Object Model (DOM) API for XML documents. It provides interfaces used by DOM implementations like xml.dom.minidom.

Complexity Reference

Operation Time Space Notes
DOM build (via implementation) O(n) O(n) Build full tree from XML input
getElementsByTagName(name) O(n) O(1) Traverses the subtree to find matches

Common Operations (minidom)

from xml.dom import minidom

# Parse XML file - O(n)
doc = minidom.parse('data.xml')

# Find elements - O(n)
items = doc.getElementsByTagName('item')
for item in items:
    print(item.firstChild.nodeValue)