MIDI output from LilyPond is usually the way one would be able to listen to
their score.
While MusicXML can be converted *to* LilyPond, the reverse is not possible to
my knowledge. There is an open issue [2] filed requesting a MusicXML backend
to LilyPond, which would enable it to output that format.
[2]: https://gitlab.com/lilypond/lilypond/-/issues/665
There have been attempts to export lilypond *to* MusicXML:
https://github.com/Philomelos/lilypond-ly2musicxml
But last commit was 8 years ago I think. Maybe there are more recent
attempts going on elsewhere?
More usabable is the MusicXML export that is
provided by python-ly using the ly command, but it is still quite buggy.
https://python-ly.readthedocs.io/en/latest/command.html
Frescobaldi uses python-ly and has an "export as MusicXML" option, but you
first have to enable experimental features in the preferences to see the
option.
--
MT