REST Api xml element with attribute

Hi Yii expert,

I am using advanced yii2 template for developing REST Api. I have achieved basic usage like url router with CRUD and custom functions also. I got struck where i need to add attributes for xml element. For example


  &lt;firstname&gt; yii &lt;/firstname&gt;

  &lt;lastname&gt; expert &lt;/lastname&gt;

  &lt;dateofbirth date = &quot;20&quot; year = &quot;1984&quot;&gt;July&lt;/dateofbirth&gt;


Is that possible to achieve?

I have already tried fields() method by overriding the dateofbirth… but i could not achieve this… any body have already done this kind of stuff in xml reponse for API.