Why does the ROS2 Python launch files look like XML written in Python?

I wasn’t able to find resources on how to do event handling on lifecycle nodes, inside ROS2 XML Launch files. Can you share some?