On this page
  1. pyexpat.ParserCreate
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

pyexpat.ParserCreate

Prev: pyexpat.ExpatError | Up: pyexpat | Next: pyexpat.XMLParserType
Rel: pyexpat.error, pyexpat.ErrorString, pyexpat.ExpatError, pyexpat.XMLParserType
Ref: docs.python.org — pyexpat.ParserCreate
Tags: #public #python3 #stdlib #pyexpat


Import

import pyexpat
from pyexpat import ParserCreate

Signature & Overview

pyexpat.ParserCreate(...)

Return a new XML parser object.

Usage

import pyexpat

tags: list[str] = []
p = pyexpat.ParserCreate()
p.StartElementHandler = lambda name, attrs: tags.append(name)
p.Parse(b"<root><item/></root>", True)
assert tags == ["root", "item"]

Gotchas

REPL Inspect

from pyexpat import ParserCreate
help(ParserCreate)

Linked from

Related notes