Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
xml.dom.minidom.Document Class Reference
Inheritance diagram for xml.dom.minidom.Document:
Inheritance graph
[legend]
Collaboration diagram for xml.dom.minidom.Document:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def appendChild
def removeChild
def unlink
def cloneNode
def createDocumentFragment
def createElement
def createTextNode
def createCDATASection
def createComment
def createProcessingInstruction
def createAttribute
def createElementNS
def createAttributeNS
def getElementById
def getElementsByTagName
def getElementsByTagNameNS
def isSupported
def importNode
def writexml
def renameNode
def __bool__
def toxml
def toprettyxml
def hasChildNodes
def insertBefore
def replaceChild
def normalize
def isSameNode
def getInterface
def getUserData
def setUserData
def __enter__
def __exit__
def abort
def load
def loadXML
def saveXML

Public Attributes

 childNodes
 documentElement

Static Public Attributes

 nodeType = Node.DOCUMENT_NODE
string nodeName = "#document"
 nodeValue = None
 attributes = None
 doctype = None
 parentNode = None
 previousSibling = nextSiblingNone
tuple implementation = DOMImplementation()
 actualEncoding = None
 encoding = None
 standalone = None
 version = None
 strictErrorChecking = False
 errorHandler = None
 documentURI = None
 namespaceURI = None
 ownerDocument = None
 nextSibling = None
 prefix = EMPTY_PREFIX
int ELEMENT_NODE = 1
int ATTRIBUTE_NODE = 2
int TEXT_NODE = 3
int CDATA_SECTION_NODE = 4
int ENTITY_REFERENCE_NODE = 5
int ENTITY_NODE = 6
int PROCESSING_INSTRUCTION_NODE = 7
int COMMENT_NODE = 8
int DOCUMENT_NODE = 9
int DOCUMENT_TYPE_NODE = 10
int DOCUMENT_FRAGMENT_NODE = 11
int NOTATION_NODE = 12
 async = False

Private Member Functions

def _get_elem_info
def _get_actualEncoding
def _get_doctype
def _get_documentURI
def _get_encoding
def _get_errorHandler
def _get_standalone
def _get_strictErrorChecking
def _get_version
def _get_documentElement
def _create_entity
def _create_notation

Private Attributes

 _elem_info
 _id_cache
 _id_search_stack

Static Private Attributes

tuple _child_node_types
int _magic_id_count = 0

Detailed Description

Definition at line 1500 of file minidom.py.


Constructor & Destructor Documentation

Definition at line 1526 of file minidom.py.

01526 
01527     def __init__(self):
01528         self.childNodes = NodeList()
01529         # mapping of (namespaceURI, localName) -> ElementInfo
01530         #        and tagName -> ElementInfo
01531         self._elem_info = {}
01532         self._id_cache = {}
01533         self._id_search_stack = None

Here is the caller graph for this function:


Member Function Documentation

def xml.dom.minidom.Node.__bool__ (   self) [inherited]

Definition at line 43 of file minidom.py.

00043 
00044     def __bool__(self):
00045         return True

def xml.dom.minidom.Node.__enter__ (   self) [inherited]

Definition at line 273 of file minidom.py.

00273 
00274     def __enter__(self):
00275         return self

def xml.dom.minidom.Node.__exit__ (   self,
  et,
  ev,
  tb 
) [inherited]

Definition at line 276 of file minidom.py.

00276 
00277     def __exit__(self, et, ev, tb):
00278         self.unlink()
00279 
00280 defproperty(Node, "firstChild", doc="First child node, or None.")
00281 defproperty(Node, "lastChild",  doc="Last child node, or None.")
00282 defproperty(Node, "localName",  doc="Namespace-local name of this node.")
00283 

Here is the call graph for this function:

def xml.dom.minidom.Document._create_entity (   self,
  name,
  publicId,
  systemId,
  notationName 
) [private]

Definition at line 1683 of file minidom.py.

01683 
01684     def _create_entity(self, name, publicId, systemId, notationName):
01685         e = Entity(name, publicId, systemId, notationName)
01686         e.ownerDocument = self
01687         return e

def xml.dom.minidom.Document._create_notation (   self,
  name,
  publicId,
  systemId 
) [private]

Definition at line 1688 of file minidom.py.

01688 
01689     def _create_notation(self, name, publicId, systemId):
01690         n = Notation(name, publicId, systemId)
01691         n.ownerDocument = self
01692         return n

Definition at line 1541 of file minidom.py.

01541 
01542     def _get_actualEncoding(self):
01543         return self.actualEncoding

def xml.dom.minidom.Document._get_doctype (   self) [private]

Definition at line 1544 of file minidom.py.

01544 
01545     def _get_doctype(self):
01546         return self.doctype

Definition at line 1593 of file minidom.py.

01593 
01594     def _get_documentElement(self):
01595         for node in self.childNodes:
01596             if node.nodeType == Node.ELEMENT_NODE:
01597                 return node

Here is the caller graph for this function:

Definition at line 1547 of file minidom.py.

01547 
01548     def _get_documentURI(self):
01549         return self.documentURI

def xml.dom.minidom.Document._get_elem_info (   self,
  element 
) [private]

Definition at line 1534 of file minidom.py.

01534 
01535     def _get_elem_info(self, element):
01536         if element.namespaceURI:
01537             key = element.namespaceURI, element.localName
01538         else:
01539             key = element.tagName
01540         return self._elem_info.get(key)

Here is the caller graph for this function:

def xml.dom.minidom.Document._get_encoding (   self) [private]

Definition at line 1550 of file minidom.py.

01550 
01551     def _get_encoding(self):
01552         return self.encoding

Definition at line 1553 of file minidom.py.

01553 
01554     def _get_errorHandler(self):
01555         return self.errorHandler

def xml.dom.minidom.Document._get_standalone (   self) [private]

Definition at line 1556 of file minidom.py.

01556 
01557     def _get_standalone(self):
01558         return self.standalone

Definition at line 1559 of file minidom.py.

01559 
01560     def _get_strictErrorChecking(self):
01561         return self.strictErrorChecking

def xml.dom.minidom.Document._get_version (   self) [private]

Definition at line 1562 of file minidom.py.

01562 
01563     def _get_version(self):
01564         return self.version

def xml.dom.xmlbuilder.DocumentLS.abort (   self) [inherited]

Definition at line 346 of file xmlbuilder.py.

00346 
00347     def abort(self):
00348         # What does it mean to "clear" a document?  Does the
00349         # documentElement disappear?
00350         raise NotImplementedError(
00351             "haven't figured out what this means yet")

def xml.dom.minidom.Document.appendChild (   self,
  node 
)

Reimplemented from xml.dom.minidom.Node.

Definition at line 1565 of file minidom.py.

01565 
01566     def appendChild(self, node):
01567         if node.nodeType not in self._child_node_types:
01568             raise xml.dom.HierarchyRequestErr(
01569                 "%s cannot be child of %s" % (repr(node), repr(self)))
01570         if node.parentNode is not None:
01571             # This needs to be done before the next test since this
01572             # may *be* the document element, in which case it should
01573             # end up re-ordered to the end.
01574             node.parentNode.removeChild(node)
01575 
01576         if node.nodeType == Node.ELEMENT_NODE \
01577            and self._get_documentElement():
01578             raise xml.dom.HierarchyRequestErr(
01579                 "two document elements disallowed")
01580         return Node.appendChild(self, node)

Here is the call graph for this function:

def xml.dom.minidom.Document.cloneNode (   self,
  deep 
)

Reimplemented from xml.dom.minidom.Node.

Definition at line 1604 of file minidom.py.

01604 
01605     def cloneNode(self, deep):
01606         if not deep:
01607             return None
01608         clone = self.implementation.createDocument(None, None, None)
01609         clone.encoding = self.encoding
01610         clone.standalone = self.standalone
01611         clone.version = self.version
01612         for n in self.childNodes:
01613             childclone = _clone_node(n, deep, clone)
01614             assert childclone.ownerDocument.isSameNode(clone)
01615             clone.childNodes.append(childclone)
01616             if childclone.nodeType == Node.DOCUMENT_NODE:
01617                 assert clone.documentElement is None
01618             elif childclone.nodeType == Node.DOCUMENT_TYPE_NODE:
01619                 assert clone.doctype is None
01620                 clone.doctype = childclone
01621             childclone.parentNode = clone
01622         self._call_user_data_handler(xml.dom.UserDataHandler.NODE_CLONED,
01623                                      self, clone)
01624         return clone

Here is the call graph for this function:

def xml.dom.minidom.Document.createAttribute (   self,
  qName 
)

Definition at line 1661 of file minidom.py.

01661 
01662     def createAttribute(self, qName):
01663         a = Attr(qName)
01664         a.ownerDocument = self
01665         a.value = ""
01666         return a

def xml.dom.minidom.Document.createAttributeNS (   self,
  namespaceURI,
  qualifiedName 
)

Definition at line 1673 of file minidom.py.

01673 
01674     def createAttributeNS(self, namespaceURI, qualifiedName):
01675         prefix, localName = _nssplit(qualifiedName)
01676         a = Attr(qualifiedName, namespaceURI, localName, prefix)
01677         a.ownerDocument = self
01678         a.value = ""
01679         return a

Here is the call graph for this function:

def xml.dom.minidom.Document.createCDATASection (   self,
  data 
)

Definition at line 1643 of file minidom.py.

01643 
01644     def createCDATASection(self, data):
01645         if not isinstance(data, str):
01646             raise TypeError("node contents must be a string")
01647         c = CDATASection()
01648         c.data = data
01649         c.ownerDocument = self
01650         return c

def xml.dom.minidom.Document.createComment (   self,
  data 
)

Definition at line 1651 of file minidom.py.

01651 
01652     def createComment(self, data):
01653         c = Comment(data)
01654         c.ownerDocument = self
01655         return c

Definition at line 1625 of file minidom.py.

01625 
01626     def createDocumentFragment(self):
01627         d = DocumentFragment()
01628         d.ownerDocument = self
01629         return d

def xml.dom.minidom.Document.createElement (   self,
  tagName 
)

Definition at line 1630 of file minidom.py.

01630 
01631     def createElement(self, tagName):
01632         e = Element(tagName)
01633         e.ownerDocument = self
01634         return e

def xml.dom.minidom.Document.createElementNS (   self,
  namespaceURI,
  qualifiedName 
)

Definition at line 1667 of file minidom.py.

01667 
01668     def createElementNS(self, namespaceURI, qualifiedName):
01669         prefix, localName = _nssplit(qualifiedName)
01670         e = Element(qualifiedName, namespaceURI, prefix)
01671         e.ownerDocument = self
01672         return e

Here is the call graph for this function:

def xml.dom.minidom.Document.createProcessingInstruction (   self,
  target,
  data 
)

Definition at line 1656 of file minidom.py.

01656 
01657     def createProcessingInstruction(self, target, data):
01658         p = ProcessingInstruction(target, data)
01659         p.ownerDocument = self
01660         return p

def xml.dom.minidom.Document.createTextNode (   self,
  data 
)

Definition at line 1635 of file minidom.py.

01635 
01636     def createTextNode(self, data):
01637         if not isinstance(data, str):
01638             raise TypeError("node contents must be a string")
01639         t = Text()
01640         t.data = data
01641         t.ownerDocument = self
01642         return t

def xml.dom.minidom.Document.getElementById (   self,
  id 
)

Definition at line 1693 of file minidom.py.

01693 
01694     def getElementById(self, id):
01695         if id in self._id_cache:
01696             return self._id_cache[id]
01697         if not (self._elem_info or self._magic_id_count):
01698             return None
01699 
01700         stack = self._id_search_stack
01701         if stack is None:
01702             # we never searched before, or the cache has been cleared
01703             stack = [self.documentElement]
01704             self._id_search_stack = stack
01705         elif not stack:
01706             # Previous search was completed and cache is still valid;
01707             # no matching node.
01708             return None
01709 
01710         result = None
01711         while stack:
01712             node = stack.pop()
01713             # add child elements to stack for continued searching
01714             stack.extend([child for child in node.childNodes
01715                           if child.nodeType in _nodeTypes_with_children])
01716             # check this node
01717             info = self._get_elem_info(node)
01718             if info:
01719                 # We have to process all ID attributes before
01720                 # returning in order to get all the attributes set to
01721                 # be IDs using Element.setIdAttribute*().
01722                 for attr in node.attributes.values():
01723                     if attr.namespaceURI:
01724                         if info.isIdNS(attr.namespaceURI, attr.localName):
01725                             self._id_cache[attr.value] = node
01726                             if attr.value == id:
01727                                 result = node
01728                             elif not node._magic_id_nodes:
01729                                 break
01730                     elif info.isId(attr.name):
01731                         self._id_cache[attr.value] = node
01732                         if attr.value == id:
01733                             result = node
01734                         elif not node._magic_id_nodes:
01735                             break
01736                     elif attr._is_id:
01737                         self._id_cache[attr.value] = node
01738                         if attr.value == id:
01739                             result = node
01740                         elif node._magic_id_nodes == 1:
01741                             break
01742             elif node._magic_id_nodes:
01743                 for attr in node.attributes.values():
01744                     if attr._is_id:
01745                         self._id_cache[attr.value] = node
01746                         if attr.value == id:
01747                             result = node
01748             if result is not None:
01749                 break
01750         return result

Here is the call graph for this function:

Definition at line 1751 of file minidom.py.

01751 
01752     def getElementsByTagName(self, name):
01753         return _get_elements_by_tagName_helper(self, name, NodeList())

Here is the call graph for this function:

def xml.dom.minidom.Document.getElementsByTagNameNS (   self,
  namespaceURI,
  localName 
)

Definition at line 1754 of file minidom.py.

01754 
01755     def getElementsByTagNameNS(self, namespaceURI, localName):
01756         return _get_elements_by_tagName_ns_helper(
01757             self, namespaceURI, localName, NodeList())

Here is the call graph for this function:

def xml.dom.minidom.Node.getInterface (   self,
  feature 
) [inherited]

Definition at line 220 of file minidom.py.

00220 
00221     def getInterface(self, feature):
00222         if self.isSupported(feature, None):
00223             return self
00224         else:
00225             return None

Here is the call graph for this function:

def xml.dom.minidom.Node.getUserData (   self,
  key 
) [inherited]

Definition at line 230 of file minidom.py.

00230 
00231     def getUserData(self, key):
00232         try:
00233             return self._user_data[key][0]
00234         except (AttributeError, KeyError):
00235             return None

def xml.dom.minidom.Node.hasChildNodes (   self) [inherited]

Definition at line 64 of file minidom.py.

00064 
00065     def hasChildNodes(self):
00066         if self.childNodes:
00067             return True
00068         else:
00069             return False

def xml.dom.minidom.Document.importNode (   self,
  node,
  deep 
)

Definition at line 1761 of file minidom.py.

01761 
01762     def importNode(self, node, deep):
01763         if node.nodeType == Node.DOCUMENT_NODE:
01764             raise xml.dom.NotSupportedErr("cannot import document nodes")
01765         elif node.nodeType == Node.DOCUMENT_TYPE_NODE:
01766             raise xml.dom.NotSupportedErr("cannot import document type nodes")
01767         return _clone_node(node, deep, self)

Here is the call graph for this function:

def xml.dom.minidom.Node.insertBefore (   self,
  newChild,
  refChild 
) [inherited]

Reimplemented in xml.dom.minidom.Entity.

Definition at line 81 of file minidom.py.

00081 
00082     def insertBefore(self, newChild, refChild):
00083         if newChild.nodeType == self.DOCUMENT_FRAGMENT_NODE:
00084             for c in tuple(newChild.childNodes):
00085                 self.insertBefore(c, refChild)
00086             ### The DOM does not clearly specify what to return in this case
00087             return newChild
00088         if newChild.nodeType not in self._child_node_types:
00089             raise xml.dom.HierarchyRequestErr(
00090                 "%s cannot be child of %s" % (repr(newChild), repr(self)))
00091         if newChild.parentNode is not None:
00092             newChild.parentNode.removeChild(newChild)
00093         if refChild is None:
00094             self.appendChild(newChild)
00095         else:
00096             try:
00097                 index = self.childNodes.index(refChild)
00098             except ValueError:
00099                 raise xml.dom.NotFoundErr()
00100             if newChild.nodeType in _nodeTypes_with_children:
00101                 _clear_id_cache(self)
00102             self.childNodes.insert(index, newChild)
00103             newChild.nextSibling = refChild
00104             refChild.previousSibling = newChild
00105             if index:
00106                 node = self.childNodes[index-1]
00107                 node.nextSibling = newChild
00108                 newChild.previousSibling = node
00109             else:
00110                 newChild.previousSibling = None
00111             newChild.parentNode = self
00112         return newChild

Here is the call graph for this function:

Here is the caller graph for this function:

def xml.dom.minidom.Node.isSameNode (   self,
  other 
) [inherited]

Definition at line 217 of file minidom.py.

00217 
00218     def isSameNode(self, other):
00219         return self is other

Here is the caller graph for this function:

def xml.dom.minidom.Document.isSupported (   self,
  feature,
  version 
)

Reimplemented from xml.dom.minidom.Node.

Definition at line 1758 of file minidom.py.

01758 
01759     def isSupported(self, feature, version):
01760         return self.implementation.hasFeature(feature, version)

def xml.dom.xmlbuilder.DocumentLS.load (   self,
  uri 
) [inherited]

Definition at line 352 of file xmlbuilder.py.

00352 
00353     def load(self, uri):
00354         raise NotImplementedError("haven't written this yet")

def xml.dom.xmlbuilder.DocumentLS.loadXML (   self,
  source 
) [inherited]

Definition at line 355 of file xmlbuilder.py.

00355 
00356     def loadXML(self, source):
00357         raise NotImplementedError("haven't written this yet")

def xml.dom.minidom.Node.normalize (   self) [inherited]

Definition at line 178 of file minidom.py.

00178 
00179     def normalize(self):
00180         L = []
00181         for child in self.childNodes:
00182             if child.nodeType == Node.TEXT_NODE:
00183                 if not child.data:
00184                     # empty text node; discard
00185                     if L:
00186                         L[-1].nextSibling = child.nextSibling
00187                     if child.nextSibling:
00188                         child.nextSibling.previousSibling = child.previousSibling
00189                     child.unlink()
00190                 elif L and L[-1].nodeType == child.nodeType:
00191                     # collapse text node
00192                     node = L[-1]
00193                     node.data = node.data + child.data
00194                     node.nextSibling = child.nextSibling
00195                     if child.nextSibling:
00196                         child.nextSibling.previousSibling = node
00197                     child.unlink()
00198                 else:
00199                     L.append(child)
00200             else:
00201                 L.append(child)
00202                 if child.nodeType == Node.ELEMENT_NODE:
00203                     child.normalize()
00204         self.childNodes[:] = L

def xml.dom.minidom.Document.removeChild (   self,
  oldChild 
)

Reimplemented from xml.dom.minidom.Node.

Definition at line 1581 of file minidom.py.

01581 
01582     def removeChild(self, oldChild):
01583         try:
01584             self.childNodes.remove(oldChild)
01585         except ValueError:
01586             raise xml.dom.NotFoundErr()
01587         oldChild.nextSibling = oldChild.previousSibling = None
01588         oldChild.parentNode = None
01589         if self.documentElement is oldChild:
01590             self.documentElement = None
01591 
01592         return oldChild

def xml.dom.minidom.Document.renameNode (   self,
  n,
  namespaceURI,
  name 
)

Definition at line 1779 of file minidom.py.

01779 
01780     def renameNode(self, n, namespaceURI, name):
01781         if n.ownerDocument is not self:
01782             raise xml.dom.WrongDocumentErr(
01783                 "cannot rename nodes from other documents;\n"
01784                 "expected %s,\nfound %s" % (self, n.ownerDocument))
01785         if n.nodeType not in (Node.ELEMENT_NODE, Node.ATTRIBUTE_NODE):
01786             raise xml.dom.NotSupportedErr(
01787                 "renameNode() only applies to element and attribute nodes")
01788         if namespaceURI != EMPTY_NAMESPACE:
01789             if ':' in name:
01790                 prefix, localName = name.split(':', 1)
01791                 if (  prefix == "xmlns"
01792                       and namespaceURI != xml.dom.XMLNS_NAMESPACE):
01793                     raise xml.dom.NamespaceErr(
01794                         "illegal use of 'xmlns' prefix")
01795             else:
01796                 if (  name == "xmlns"
01797                       and namespaceURI != xml.dom.XMLNS_NAMESPACE
01798                       and n.nodeType == Node.ATTRIBUTE_NODE):
01799                     raise xml.dom.NamespaceErr(
01800                         "illegal use of the 'xmlns' attribute")
01801                 prefix = None
01802                 localName = name
01803         else:
01804             prefix = None
01805             localName = None
01806         if n.nodeType == Node.ATTRIBUTE_NODE:
01807             element = n.ownerElement
01808             if element is not None:
01809                 is_id = n._is_id
01810                 element.removeAttributeNode(n)
01811         else:
01812             element = None
01813         # avoid __setattr__
01814         d = n.__dict__
01815         d['prefix'] = prefix
01816         d['localName'] = localName
01817         d['namespaceURI'] = namespaceURI
01818         d['nodeName'] = name
01819         if n.nodeType == Node.ELEMENT_NODE:
01820             d['tagName'] = name
01821         else:
01822             # attribute node
01823             d['name'] = name
01824             if element is not None:
01825                 element.setAttributeNode(n)
01826                 if is_id:
01827                     element.setIdAttributeNode(n)
01828         # It's not clear from a semantic perspective whether we should
01829         # call the user data handlers for the NODE_RENAMED event since
01830         # we're re-using the existing node.  The draft spec has been
01831         # interpreted as meaning "no, don't call the handler unless a
01832         # new node is created."
01833         return n
01834 
01835 defproperty(Document, "documentElement",
01836             doc="Top-level element of this document.")
01837 

Here is the call graph for this function:

def xml.dom.minidom.Node.replaceChild (   self,
  newChild,
  oldChild 
) [inherited]

Reimplemented in xml.dom.minidom.Entity.

Definition at line 130 of file minidom.py.

00130 
00131     def replaceChild(self, newChild, oldChild):
00132         if newChild.nodeType == self.DOCUMENT_FRAGMENT_NODE:
00133             refChild = oldChild.nextSibling
00134             self.removeChild(oldChild)
00135             return self.insertBefore(newChild, refChild)
00136         if newChild.nodeType not in self._child_node_types:
00137             raise xml.dom.HierarchyRequestErr(
00138                 "%s cannot be child of %s" % (repr(newChild), repr(self)))
00139         if newChild is oldChild:
00140             return
00141         if newChild.parentNode is not None:
00142             newChild.parentNode.removeChild(newChild)
00143         try:
00144             index = self.childNodes.index(oldChild)
00145         except ValueError:
00146             raise xml.dom.NotFoundErr()
00147         self.childNodes[index] = newChild
00148         newChild.parentNode = self
00149         oldChild.parentNode = None
00150         if (newChild.nodeType in _nodeTypes_with_children
00151             or oldChild.nodeType in _nodeTypes_with_children):
00152             _clear_id_cache(self)
00153         newChild.nextSibling = oldChild.nextSibling
00154         newChild.previousSibling = oldChild.previousSibling
00155         oldChild.nextSibling = None
00156         oldChild.previousSibling = None
00157         if newChild.previousSibling:
00158             newChild.previousSibling.nextSibling = newChild
00159         if newChild.nextSibling:
00160             newChild.nextSibling.previousSibling = newChild
00161         return oldChild

Here is the call graph for this function:

def xml.dom.xmlbuilder.DocumentLS.saveXML (   self,
  snode 
) [inherited]

Definition at line 358 of file xmlbuilder.py.

00358 
00359     def saveXML(self, snode):
00360         if snode is None:
00361             snode = self
00362         elif snode.ownerDocument is not self:
00363             raise xml.dom.WrongDocumentErr()
00364         return snode.toxml()
00365 

def xml.dom.minidom.Node.setUserData (   self,
  key,
  data,
  handler 
) [inherited]

Definition at line 236 of file minidom.py.

00236 
00237     def setUserData(self, key, data, handler):
00238         old = None
00239         try:
00240             d = self._user_data
00241         except AttributeError:
00242             d = {}
00243             self._user_data = d
00244         if key in d:
00245             old = d[key][0]
00246         if data is None:
00247             # ignore handlers passed for None
00248             handler = None
00249             if old is not None:
00250                 del d[key]
00251         else:
00252             d[key] = (data, handler)
00253         return old

def xml.dom.minidom.Node.toprettyxml (   self,
  indent = "\t",
  newl = "\n",
  encoding = None 
) [inherited]

Definition at line 49 of file minidom.py.

00049 
00050     def toprettyxml(self, indent="\t", newl="\n", encoding=None):
00051         # indent = the indentation string to prepend, per level
00052         # newl = the newline string to append
00053         use_encoding = "utf-8" if encoding is None else encoding
00054         writer = codecs.getwriter(use_encoding)(io.BytesIO())
00055         if self.nodeType == Node.DOCUMENT_NODE:
00056             # Can pass encoding only to document, to put it into XML header
00057             self.writexml(writer, "", indent, newl, encoding)
00058         else:
00059             self.writexml(writer, "", indent, newl)
00060         if encoding is None:
00061             return writer.stream.getvalue().decode(use_encoding)
00062         else:
00063             return writer.stream.getvalue()

Here is the call graph for this function:

Here is the caller graph for this function:

def xml.dom.minidom.Node.toxml (   self,
  encoding = None 
) [inherited]

Definition at line 46 of file minidom.py.

00046 
00047     def toxml(self, encoding=None):
00048         return self.toprettyxml("", "", encoding)

Here is the call graph for this function:

Reimplemented from xml.dom.minidom.Node.

Definition at line 1598 of file minidom.py.

01598 
01599     def unlink(self):
01600         if self.doctype is not None:
01601             self.doctype.unlink()
01602             self.doctype = None
01603         Node.unlink(self)

def xml.dom.minidom.Document.writexml (   self,
  writer,
  indent = "",
  addindent = "",
  newl = "",
  encoding = None 
)

Definition at line 1769 of file minidom.py.

01769 
01770                  encoding = None):
01771         if encoding is None:
01772             writer.write('<?xml version="1.0" ?>'+newl)
01773         else:
01774             writer.write('<?xml version="1.0" encoding="%s"?>%s' % (encoding, newl))
01775         for node in self.childNodes:
01776             node.writexml(writer, indent, addindent, newl)

Here is the caller graph for this function:


Member Data Documentation

Initial value:
(Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE,
                         Node.COMMENT_NODE, Node.DOCUMENT_TYPE_NODE)

Definition at line 1501 of file minidom.py.

Definition at line 1530 of file minidom.py.

Definition at line 1531 of file minidom.py.

Definition at line 1532 of file minidom.py.

Definition at line 1524 of file minidom.py.

Definition at line 1516 of file minidom.py.

xml.dom.xmlbuilder.DocumentLS.async = False [static, inherited]

Definition at line 337 of file xmlbuilder.py.

int xml.dom.Node.ATTRIBUTE_NODE = 2 [static, inherited]

Definition at line 29 of file __init__.py.

Definition at line 1507 of file minidom.py.

int xml.dom.Node.CDATA_SECTION_NODE = 4 [static, inherited]

Definition at line 31 of file __init__.py.

Reimplemented from xml.dom.minidom.Node.

Definition at line 1527 of file minidom.py.

int xml.dom.Node.COMMENT_NODE = 8 [static, inherited]

Definition at line 35 of file __init__.py.

Definition at line 1508 of file minidom.py.

int xml.dom.Node.DOCUMENT_FRAGMENT_NODE = 11 [static, inherited]

Definition at line 38 of file __init__.py.

int xml.dom.Node.DOCUMENT_NODE = 9 [static, inherited]

Definition at line 36 of file __init__.py.

int xml.dom.Node.DOCUMENT_TYPE_NODE = 10 [static, inherited]

Definition at line 37 of file __init__.py.

Definition at line 1589 of file minidom.py.

Definition at line 1522 of file minidom.py.

int xml.dom.Node.ELEMENT_NODE = 1 [static, inherited]

Definition at line 28 of file __init__.py.

Definition at line 1517 of file minidom.py.

int xml.dom.Node.ENTITY_NODE = 6 [static, inherited]

Definition at line 33 of file __init__.py.

int xml.dom.Node.ENTITY_REFERENCE_NODE = 5 [static, inherited]

Definition at line 32 of file __init__.py.

Definition at line 1521 of file minidom.py.

Definition at line 1512 of file minidom.py.

xml.dom.minidom.Node.namespaceURI = None [static, inherited]

Reimplemented in xml.dom.minidom.Element.

Definition at line 35 of file minidom.py.

xml.dom.minidom.Node.nextSibling = None [static, inherited]

Definition at line 38 of file minidom.py.

string xml.dom.minidom.Document.nodeName = "#document" [static]

Definition at line 1505 of file minidom.py.

Reimplemented from xml.dom.minidom.Node.

Definition at line 1504 of file minidom.py.

Definition at line 1506 of file minidom.py.

int xml.dom.Node.NOTATION_NODE = 12 [static, inherited]

Definition at line 39 of file __init__.py.

xml.dom.minidom.Node.ownerDocument = None [static, inherited]

Definition at line 37 of file minidom.py.

Reimplemented from xml.dom.minidom.Node.

Definition at line 1509 of file minidom.py.

Reimplemented in xml.dom.minidom.Element.

Definition at line 41 of file minidom.py.

xml.dom.minidom.Document.previousSibling = nextSiblingNone [static]

Reimplemented from xml.dom.minidom.Node.

Definition at line 1510 of file minidom.py.

Definition at line 34 of file __init__.py.

Definition at line 1518 of file minidom.py.

Definition at line 1520 of file minidom.py.

int xml.dom.Node.TEXT_NODE = 3 [static, inherited]

Definition at line 30 of file __init__.py.

Definition at line 1519 of file minidom.py.


The documentation for this class was generated from the following file: