Skip to content

Commit 33eec1a

Browse files
committed
Document some methods of xml.dom.minidom.Element class
1 parent 303475e commit 33eec1a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Lib/xml/dom/minidom.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,14 @@ def unlink(self):
718718
Node.unlink(self)
719719

720720
def getAttribute(self, attname):
721+
"""Returns the value of the specified attribute.
722+
723+
Returns the value of the element's attribute named attname as
724+
a string. An empty string is returned if the element does not
725+
have such an attribute. Note that an empty string may also be
726+
returned as an explicitly given attribute value, use the
727+
hasAttribute method to distinguish these two cases.
728+
"""
721729
if self._attrs is None:
722730
return ""
723731
try:
@@ -828,6 +836,11 @@ def removeAttributeNode(self, node):
828836
removeAttributeNodeNS = removeAttributeNode
829837

830838
def hasAttribute(self, name):
839+
"""Checks whether the element has an attribute with the specified name.
840+
841+
Returns True if the element has an attribute with the specified name.
842+
Otherwise, returns False.
843+
"""
831844
if self._attrs is None:
832845
return False
833846
return name in self._attrs
@@ -838,6 +851,11 @@ def hasAttributeNS(self, namespaceURI, localName):
838851
return (namespaceURI, localName) in self._attrsNS
839852

840853
def getElementsByTagName(self, name):
854+
"""Returns all descendant elements with the given tag name.
855+
856+
Returns the list of all descendant elements (not direct children
857+
only) with the specified tag name.
858+
"""
841859
return _get_elements_by_tagName_helper(self, name, NodeList())
842860

843861
def getElementsByTagNameNS(self, namespaceURI, localName):
@@ -848,6 +866,11 @@ def __repr__(self):
848866
return "<DOM Element: %s at %#x>" % (self.tagName, id(self))
849867

850868
def writexml(self, writer, indent="", addindent="", newl=""):
869+
"""Write an XML element to a file-like object
870+
871+
Write the element to the writer object that must provide
872+
a write method (e.g. a file or StringIO object).
873+
"""
851874
# indent = current indentation
852875
# addindent = indentation to add to higher levels
853876
# newl = newline string

0 commit comments

Comments
 (0)