STYLE: Fixed redefined-outer-name linting issue
Fixed `redefined-outer-name` linting issue in the following files (Towards #49656)

* `pandas/core/indexes/datetimes.py`
* `pandas/io/formats/xml.py`
* `pandas/io/json/_table_schema.py`
@MarcoGorelli Addressed the requested changes in `xml.py` and `datetimes.py`. Could you please review and let me know of any required changes? Hey @aditya-anulekh. LGTM, but needs a rebase.