Lines Matching refs:XML
1 :mod:`xml.etree.ElementTree` --- The ElementTree XML API
14 for parsing and creating XML data.
34 XML tree and elements
37 XML is an inherently hierarchical data format, and the most natural way to
39 :class:`ElementTree` represents the whole XML document as a tree, and
42 on the :class:`ElementTree` level. Interactions with a single XML element
47 Parsing XML
50 We'll be using the following XML document as the sample data for this section:
88 :func:`fromstring` parses XML from a string directly into an :class:`Element`,
116 Not all elements of the XML input will end up as elements of the
117 parsed tree. Currently, this module skips over any XML comments,
120 than parsing from XML text can have comments and processing
121 instructions in them; they will be included when generating XML
136 most needs. Sometimes what the user really wants is to be able to parse XML
141 require a blocking read to obtain the XML data, and is instead fed with data
142 incrementally with :meth:`XMLPullParser.feed` calls. To get the parsed XML
157 where the XML data is being received from a socket or read incrementally from
161 simpler use-cases. If you don't mind your application blocking on reading XML
163 at :func:`iterparse`. It can be useful when you're reading a large XML document
199 Modifying an XML File
202 :class:`ElementTree` provides a simple way to build XML documents and write them to files.
220 Our XML now looks like this:
258 Our XML now looks like this:
279 Building XML documents
292 Parsing XML with Namespaces
295 If the XML input has `namespaces
303 Here is an XML example that incorporates two namespaces, one with the
324 One way to search and explore this XML example is to manually add the
335 A better way to search the namespaced XML example is to create a
379 module. We'll be using the ``countrydata`` XML document from the
380 :ref:`Parsing XML <elementtree-parsing-xml>` section::
472 that will be serialized as an XML comment by the standard serializer. The
488 written as an ordinary XML file.
495 Parses an XML section from a string constant. Same as :func:`XML`. *text*
496 is a string containing XML data. *parser* is an optional parser instance.
503 Parses an XML document from a sequence of string fragments. *sequence* is a
504 list or other sequence containing XML data fragments. *parser* is an
519 Parses an XML section into an element tree incrementally, and reports what's
521 containing XML data. *events* is a sequence of events to report back. The
550 Parses an XML section into an element tree. *source* is a filename or file
551 object containing XML data. *parser* is an optional parser instance. If
559 will be serialized as an XML processing instruction. *target* is a string
595 Generates a string representation of an XML element, including all
601 Returns an (optionally) encoded string containing the XML data.
610 Generates a string representation of an XML element, including all
616 Returns a list of (optionally) encoded strings containing the XML data.
626 .. function:: XML(text, parser=None)
628 Parses an XML section from a string constant. This function can be used to
629 embed "XML literals" in Python code. *text* is a string containing XML
636 Parses an XML section from a string constant, and also returns a dictionary
637 which maps from element id:s to elements. *text* is a string containing XML
671 an XML file, the *text* attribute holds either the text between
674 end tag and the next tag, or ``None``. For the XML data
863 standard XML.
866 of the XML *file* if given.
918 Loads an external XML section into this element tree. *source* is a file
928 Writes the element tree to a file, as XML. *file* is a file name, or a
931 *xml_declaration* controls if an XML declaration should be added to the
934 *default_namespace* sets the default XML namespace (for "xmlns").
953 This is the XML file that is going to be manipulated::
1008 can use this class to build an element structure using a custom XML parser,
1009 or a parser for some other XML-like format. *element_factory*, when given,
1058 :mod:`xml.parsers.expat` for efficient, event-based parsing of XML. It can
1059 be fed XML data incrementally with the :meth:`feed` method, and parsing
1064 encoding specified in the XML file.
1093 of an XML file::
1186 XML parse error, raised by the various parsing methods in this module when
1202 .. [1] The encoding string included in XML output should conform to the