Parsing XML file deletes whitespace. How to avoid it?

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/learnpython

Our great sponsors
  • InfluxDB - Access the most powerful time series database as a service
  • Sonar - Write Clean Python Code. Always.
  • SaaSHub - Software Alternatives and Reviews
  • CPython

    The Python programming language

    If I read this correctly this behavior appears to be a bug that has seemingly been fixed for Python 3.9. What's your Python version?

  • lxml

    The lxml XML toolkit for Python

    I got curious about this now so I did some tests on my own, and it appears that the XML parser implementation in Python does indeed strip all newline characters from attributes. Whether this is according to XML standard I do not know; I also briefly tried an alternative XML implementation for Python and it behaves the same, so I would assume that this is standard behavior, but I'm not knowledgable enough about XML to say for certain.

  • InfluxDB

    Access the most powerful time series database as a service. Ingest, store, & analyze all types of time series data in a fully-managed, purpose-built database. Keep data forever with low-cost storage and superior data compression.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts