MCPcopy
hub / github.com/scrapy/scrapy / _export_xml_field

Method _export_xml_field

scrapy/exporters.py:203–221  ·  view source on GitHub ↗
(self, name: str, serialized_value: Any, depth: int)

Source from the content-addressed store, hash-verified

201 self.xg.endDocument()
202
203 def _export_xml_field(self, name: str, serialized_value: Any, depth: int) -> None:
204 self._beautify_indent(depth=depth)
205 self.xg.startElement(name, AttributesImpl({}))
206 if hasattr(serialized_value, "items"):
207 self._beautify_newline()
208 for subname, value in serialized_value.items():
209 self._export_xml_field(subname, value, depth=depth + 1)
210 self._beautify_indent(depth=depth)
211 elif is_listlike(serialized_value):
212 self._beautify_newline()
213 for value in serialized_value:
214 self._export_xml_field("value", value, depth=depth + 1)
215 self._beautify_indent(depth=depth)
216 elif isinstance(serialized_value, str):
217 self.xg.characters(serialized_value)
218 else:
219 self.xg.characters(str(serialized_value))
220 self.xg.endElement(name)
221 self._beautify_newline()
222
223
224class CsvItemExporter(BaseItemExporter):

Callers 1

export_itemMethod · 0.95

Calls 4

_beautify_indentMethod · 0.95
_beautify_newlineMethod · 0.95
is_listlikeFunction · 0.90
itemsMethod · 0.80

Tested by

no test coverage detected