How to scrape data from an xml?

What do you want to scrape in here? Is it to replace your workaround?
This is all that I have to scrape my wattage out of the XML, I did not need any more info from my inverter:

    - name: "Solar AC Power"
      unique_id: solar_ac_power
      unit_of_measurement: "W"
      icon: 'mdi:solar-power'
      json_attributes_path: $.root.Device.Measurements.Measurement[2]
      json_attributes:
        - Value
      value_template: "{{ value_json.root.Device.Measurements.Measurement[2]['@Value'] }}"
      device_class: energy
      state_class: measurement

If there is no data provided at night by my inverter the sensor in Home-Assistant just shows 0, I did not have to configure anything for that. The ‘0’ is also 1 measurement so not every 2 seconds, when the inverter starts when there is sun again the scrapper automatically begins. So sorry, I don’t have a clue for that.

I have a different inverter btw, the StecaGrid 3611.