martinblech / xmltodict

Python module that makes working with XML feel like you are working with JSON
MIT License
5.48k stars 461 forks source link

force datatype #230

Open yan-hic opened 4 years ago

yan-hic commented 4 years ago

Currently parsing a XML renders string values only, so xmltodict cannot be used e.g. as input of fastavro if the avro schema has a mix of data types.

Enhancement request is to have a optional argument like forced_list but for (key, datatype) tuples or similar syntax. The comment https://github.com/martinblech/xmltodict/pull/104#issuecomment-104944964 would actually meet both requirements.

Alternative: write complex post-processing function.

Note another library, xmlschema, uses the datatypes defined in a xml schema file, if available. But this is much slower than xmltodict especially if only a few fields should be force-converted.

nitingarg1234 commented 4 years ago

Facing same issue.