Name
parseString
Synopsis
parseString(string
,parser
=None)
Like parse
, except that
string
is the XML document in string form.
xml.dom.minidom
also supplies many classes as
specified by the XML DOM standard. Almost all of these classes
subclass Node
. Class Node
supplies the methods and attributes that all kinds of nodes have in
common. A notable class of module xml.dom.minidom
that is not a subclass of Node
is
AttributeList
, identified in the DOM standard as
NamedNodeMap
, which is a mapping that collects the
attributes of a node of class
Element
.
For methods and attributes related to changing and creating XML
documents, see Section 23.4 later in this chapter. Here, I present the
classes, methods, and attributes that you use most often when
traversing a DOM tree without changes, normally after the tree has
been built by parsing an XML document. For concreteness and
simplicity, I mention Python classes. However, the DOM specifications
deal strictly with abstract interfaces, never with concrete classes.
Your code must never deal with the class objects directly, only with
instances of those classes. Do not type-test nodes (for example,
don’t use isinstance
on them) and
do not instantiate node classes directly (rather, use the factory
methods covered later in Section 23.4). This is good Python
practice in general, but it’s particularly important
here.
Get Python in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.