pyexpat — Python wrapper for Expat parser 🐍⚡
| Use Case | Command | Description |
|---|---|---|
| 🔧 Create parser | pyexpat.ParserCreate(...) |
🔨 Return a new XML parser object |
| 📄 Parse XML string | xmlparser.Parse(data, isfinal=False) |
📥 Parse XML data — set isfinal=True at end of input |
| 📁 Parse XML file | xmlparser.ParseFile(file) |
📂 Parse XML data from a file-like object |
| 🌐 Set base URL | xmlparser.SetBase(base) |
📍 Set the base URL for the parser |
| ❌ Get error string | pyexpat.ErrorString(code) |
💬 Return string error description for given error number |
| 🔗 External entity parser | xmlparser.ExternalEntityParserCreate(...) |
🌍 Create a parser for parsing an external entity based on info passed to ExternalEntityRefHandler |
| 📏 Get input context | xmlparser.GetInputContext() |
📝 Return the untranslated text of the input that caused the current event |
| ⚙️ Set param entity parsing | xmlparser.SetParamEntityParsing(flag) |
🎛️ Controls parsing of parameter entities (including external DTD subset) |
| 🌐 Use foreign DTD | xmlparser.UseForeignDTD(flag=True) |
📜 Allows the application to provide an artificial external subset if one is not specified |
errorsmodelbuiltins.Exception(builtins.BaseException) → xml.parsers.expat.ExpatErrorbuiltins.object → xmlparserclass ExpatError(builtins.Exception)
| Method resolution order:
| ExpatError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __delattr__(self, name, /)
| Implement delattr(self, name).
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setattr__(self, name, value, /)
| Implement setattr(self, name, value).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
🔁 The error attribute is an alias for ExpatError.
XMLParserType = class xmlparser(builtins.object)
| XML parser
|
| Methods defined here:
ExternalEntityParserCreate(...) — 🌍 Create a parser for parsing an external entity based on the information passed to the ExternalEntityRefHandler.GetBase(self, /) — 📍 Return base URL string for the parser.GetInputContext(self, /) — 📝 Return the untranslated text of the input that caused the current event. If the event was generated by a large amount of text (such as a start tag for an element with many attributes), not all of the text may be available.Parse(self, data, isfinal=False, /) — 📥 Parse XML data. isfinal should be true at end of input.ParseFile(self, file, /) — 📂 Parse XML data from file-like object.SetBase(self, base, /) — 📍 Set the base URL for the parser.SetParamEntityParsing(self, flag, /) — 🎛️ Controls parsing of parameter entities (including the external DTD subset). Possible flag values are XML_PARAM_ENTITY_PARSING_NEVER, XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE and XML_PARAM_ENTITY_PARSING_ALWAYS. Returns true if setting the flag was successful.UseForeignDTD(self, flag=True, /) — 🌐 Allows the application to provide an artificial external subset if one is not specified as part of the document instance. This readily allows the use of a 'default' document type controlled by the application, while still getting the advantage of providing document type information to the parser. flag defaults to True if not provided. | ----------------------------------------------------------------------
| Data descriptors defined here:
AttlistDeclHandlerCharacterDataHandlerCommentHandlerCurrentByteIndexCurrentColumnNumberCurrentLineNumberDefaultHandlerDefaultHandlerExpandElementDeclHandlerEndCdataSectionHandlerEndDoctypeDeclHandlerEndElementHandlerEndNamespaceDeclHandlerEntityDeclHandlerErrorByteIndexErrorCodeErrorColumnNumberErrorLineNumberExternalEntityRefHandlerNotStandaloneHandlerNotationDeclHandlerProcessingInstructionHandlerSkippedEntityHandlerStartCdataSectionHandlerStartDoctypeDeclHandlerStartElementHandlerStartNamespaceDeclHandlerUnparsedEntityDeclHandlerXmlDeclHandlerbuffer_sizebuffer_textbuffer_usedinternnamespace_prefixesordered_attributesspecified_attributesErrorString(code, /) — 💬 Returns string error for given number.ParserCreate(...) — 🔨 Return a new XML parser object.EXPAT_VERSION = 'expat_2.4.7'XML_PARAM_ENTITY_PARSING_ALWAYS = 2XML_PARAM_ENTITY_PARSING_NEVER = 0XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE = 1expat_CAPI = <capsule object "pyexpat.expat_CAPI">features = [('sizeof(XML_Char)', 1), ('sizeof(XML_LChar)', 1), ('XML_D...native_encoding = 'UTF-8'version_info = (2, 4, 7)(built-in)
Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-01 17:02 @216.73.216.239
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)