@@ -718,6 +718,14 @@ def unlink(self):
718
718
Node .unlink (self )
719
719
720
720
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
+ """
721
729
if self ._attrs is None :
722
730
return ""
723
731
try :
@@ -828,6 +836,11 @@ def removeAttributeNode(self, node):
828
836
removeAttributeNodeNS = removeAttributeNode
829
837
830
838
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
+ """
831
844
if self ._attrs is None :
832
845
return False
833
846
return name in self ._attrs
@@ -838,6 +851,11 @@ def hasAttributeNS(self, namespaceURI, localName):
838
851
return (namespaceURI , localName ) in self ._attrsNS
839
852
840
853
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
+ """
841
859
return _get_elements_by_tagName_helper (self , name , NodeList ())
842
860
843
861
def getElementsByTagNameNS (self , namespaceURI , localName ):
@@ -848,6 +866,11 @@ def __repr__(self):
848
866
return "<DOM Element: %s at %#x>" % (self .tagName , id (self ))
849
867
850
868
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
+ """
851
874
# indent = current indentation
852
875
# addindent = indentation to add to higher levels
853
876
# newl = newline string
0 commit comments