MCPcopy Index your code
hub / github.com/python/cpython / writexml

Method writexml

Lib/xml/dom/minidom.py:882–912  ·  view source on GitHub ↗

Write an XML element to a file-like object Write the element to the writer object that must provide a write method (e.g. a file or StringIO object).

(self, writer, indent="", addindent="", newl="")

Source from the content-addressed store, hash-verified

880 return "<DOM Element: %s at %#x>" % (self.tagName, id(self))
881
882 def writexml(self, writer, indent="", addindent="", newl=""):
883 """Write an XML element to a file-like object
884
885 Write the element to the writer object that must provide
886 a write method (e.g. a file or StringIO object).
887 """
888 # indent = current indentation
889 # addindent = indentation to add to higher levels
890 # newl = newline string
891 writer.write(indent+"<" + self.tagName)
892
893 attrs = self._get_attributes()
894
895 for a_name in attrs.keys():
896 writer.write(" %s=\"" % a_name)
897 _write_data(writer, attrs[a_name].value, True)
898 writer.write("\"")
899 if self.childNodes:
900 writer.write(">")
901 if (len(self.childNodes) == 1 and
902 self.childNodes[0].nodeType in (
903 Node.TEXT_NODE, Node.CDATA_SECTION_NODE)):
904 self.childNodes[0].writexml(writer, '', '', '')
905 else:
906 writer.write(newl)
907 for node in self.childNodes:
908 node.writexml(writer, indent+addindent, addindent, newl)
909 writer.write(indent)
910 writer.write("</%s>%s" % (self.tagName, newl))
911 else:
912 writer.write("/>%s"%(newl))
913
914 def _get_attributes(self):
915 self._ensure_attributes()

Callers

nothing calls this directly

Calls 5

_get_attributesMethod · 0.95
_write_dataFunction · 0.85
writeMethod · 0.45
keysMethod · 0.45
writexmlMethod · 0.45

Tested by

no test coverage detected