pugixml.pugi.FileWriter
- class pugixml.pugi.FileWriter
Bases:
XMLWriterXMLWriterimplementation for a file.If writing to a file fails, an
OSErroris raised.See also
Examples
>>> from contextlib import closing >>> from pugixml import pugi >>> doc = pugi.XMLDocument() >>> doc.load_string('<node><child>\U0001f308</child></node>') >>> with closing(pugi.FileWriter('tree.xml')) as writer: ... doc.save(writer)
Methods
__init__(self, file)Initialize
FileWriter.close(self)Close the associated file.
Member Documentation
- __init__(self: pugixml.pugi.FileWriter, file: os.PathLike | str | bytes) None
Initialize
FileWriter.Open a file for writing and associate it with this object.
- Parameters:
file – The path of the file to save the XML document or a single subtree.
- Raises:
OSError – When a file fails to open.
- close(self: pugixml.pugi.FileWriter) None
Close the associated file.