@@ -719,6 +719,14 @@ def unlink(self):
719
719
Node .unlink (self )
720
720
721
721
def getAttribute (self , attname ):
722
+ """Returns the value of the specified attribute.
723
+
724
+ Returns the value of the element's attribute named attname as
725
+ a string. An empty string is returned if the element does not
726
+ have such an attribute. Note that an empty string may also be
727
+ returned as an explicitly given attribute value, use the
728
+ hasAttribute method to distinguish these two cases.
729
+ """
722
730
if self ._attrs is None :
723
731
return ""
724
732
try :
@@ -829,6 +837,11 @@ def removeAttributeNode(self, node):
829
837
removeAttributeNodeNS = removeAttributeNode
830
838
831
839
def hasAttribute (self , name ):
840
+ """Checks whether the element has an attribute with the specified name.
841
+
842
+ Returns True if the element has an attribute with the specified name.
843
+ Otherwise, returns False.
844
+ """
832
845
if self ._attrs is None :
833
846
return False
834
847
return name in self ._attrs
@@ -839,6 +852,11 @@ def hasAttributeNS(self, namespaceURI, localName):
839
852
return (namespaceURI , localName ) in self ._attrsNS
840
853
841
854
def getElementsByTagName (self , name ):
855
+ """Returns all descendant elements with the given tag name.
856
+
857
+ Returns the list of all descendant elements (not direct children
858
+ only) with the specified tag name.
859
+ """
842
860
return _get_elements_by_tagName_helper (self , name , NodeList ())
843
861
844
862
def getElementsByTagNameNS (self , namespaceURI , localName ):
@@ -849,6 +867,11 @@ def __repr__(self):
849
867
return "<DOM Element: %s at %#x>" % (self .tagName , id (self ))
850
868
851
869
def writexml (self , writer , indent = "" , addindent = "" , newl = "" ):
870
+ """Write an XML element to a file-like object
871
+
872
+ Write the element to the writer object that must provide
873
+ a write method (e.g. a file or StringIO object).
874
+ """
852
875
# indent = current indentation
853
876
# addindent = indentation to add to higher levels
854
877
# newl = newline string
0 commit comments