Restufl and json data

Hello all, I have a new device I can speak to using Rest. I managed to configure it on Node-red but I would like to configure it on HA too.

The XML I get from the device is something like this:

<dev xmlns="xmlns-rest-url" version="1.0">
<value advTextOffset="0" unit="kg" uri="/user/var/90/63/0/0/12015" strValue="135" scaleFactor="10" decPlaces="0">1349</value>
</dev>

I tried to configure a sensor via restful this way:

- platform: rest
  name: My device
  resource: http://192.168.1.90:63/user/var/90/63/0/0/12015
  timeout: 30
  value_template: >
    {% if value[0].unit is defined %}
      "{{ value[0].unit }}"
    {% else %}
      "Undefined"
    {% endif %}

But I am unable to get the value (I tried with unit, uri, strValue and so on). What am I doing wrong?

Try this:

  value_template: "{{ value_json['dev']['value']['@unit'] }}"

See Converting Between XML and JSON

Thanks @ondras12345 it works!